I think I'm a step closer now.
I created an inner div with
text-align:center;...removed the float-left on
.topnav aand set
.topnav a to inline-block
The only problem now, is the first link is not left aligned, when viewed on a mobile - it is centered.
Any ideas how I could left align the first link?
CODE
<style type="text/css">
.topnav {
overflow: hidden;
background-color: #d1270b;
margin: 10px 0;
}
.topnav a {
display: inline-block;
color: #FFFFFF!important;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #d1270b;
color: #ffffff!important;
text-decoration: underline;
}
.active {
background-color: #d1270b;
color: white;
}
.topnav .icon {
display: none;
}
@media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
@media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
</style>
CODE
<div class="topnav" id="myTopnav">
<div style="text-align: center;">
<a href="/">Home</a>
<a href="/articles">Articles</a>
<a href="/downloads">Downloads</a>
<a href="/forum" class="active">Forum</a>
<a href="/dir/products/updated">Products</a>
<a href="/dir/services">Services</a>
<a href="/contact">Contact</a>
<a href="java script:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a>
</div>
</div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>