Do you think your HTML
code is correct? Let's take a closer look.
<div class="Header">
</div>
<ul class="menu">
<li>Home </li>
<li>Over mij </li>
<li>Mijn diensten </li>
<li>Contact </li>
</ul>
Instead of:
<div class="Header">
<ul class="menu">
<li>Home </li>
<li>Over mij </li>
<li>Mijn diensten </li>
<li>Contact </li>
</ul>
</div>
I recommend verifying this first.
Next, let's address the centering of your menu
. By examining your CSS
and adjusting the background-color
, we can clarify things.
.wrapper {
width: 100%;
}
.menudiv {
width: 80%;
border: 1px red solid;
margin: auto;
}
.menu {
border: 1px red solid;
padding: 55px 0;
position: relative;
display:inline-block;
transform: translateX(-50%);
left: 50%;
color: black;
width: 80%;
}
.menu li {
float: left;
display: block;
padding-right: 5%;
}
.menu li:after {
content:'/';
padding-left: 20px;
}
div.wrapper {
background-color: orange;
}
<title>Webdesign Maarten</title>
<body>
<div class="wrapper">
<div class="header">
<!-- here to put image JQuery preferably Sliding !-->
</div>
<div class="Header">
<!-- menu float left indent with icon centered view v wrap. no list style -->
</div>
<ul class="menu">
<li>Home</li>
<li>About Me</li>
<li>My Services</li>
<li>Contact</li>
</ul>
</div>
</body>
</html>
Now, for the solutions. There are two possibilities I can suggest based on your requirements.
Solution 1:
Adjust the .menu li
class as shown below :
.menu li {
display: block;
text-align: center;
}
See updated code below :
.wrapper {
width: 100%;
}
.menudiv {
width: 80%;
border: 1px red solid;
margin: auto;
}
.menu {
border: 1px red solid;
padding: 55px 0;
position: relative;
display:inline-block;
transform: translateX(-50%);
left: 50%;
color: black;
width: 80%;
}
.menu li {
display: block;
text-align: center;
}
.menu li:after {
content:'/';
padding-left: 20px;
}
<title>Webdesign Maarten</title>
<body>
<div class="wrapper">
<div class="header">
<!-- here to put image JQuery preferably Sliding !-->
</div>
<div class="Header">
<!-- menu float left indent with icon centered view v wrap. no list style -->
<ul class="menu">
<li>Home</li>
<li>About Me</li>
<li>My Services</li>
<li>Contact</li>
</ul>
</div>
</div>
</body>
</html>
Solution 2:
Modify the .menu
and .menu li
class like so :
.menu {
border: 1px red solid;
padding: 55px 0;
position: relative;
display:inline-block;
transform: translateX(-50%);
left: 50%;
color: black;
width: 80%;
text-align: center; /*Add this property*/
}
.menu li {
display: block;
text-align: center;
}
See updated code below :
.wrapper {
width: 100%;
}
.menudiv {
width: 80%;
border: 1px red solid;
margin: auto;
}
.menu {
border: 1px red solid;
padding: 55px 0;
position: relative;
display:inline-block;
transform: translateX(-50%);
left: 50%;
color: black;
width: 80%;
text-align: center;
}
.menu li {
display: inline-block;
text-align: center;
}
.menu li:after {
content:'/';
padding-left: 20px;
}
<title>Webdesign Maarten</title>
<body>
<div class="wrapper">
<div class="header">
<!-- here to put image JQuery preferably Sliding !-->
</div>
<div class="Header">
<!-- menu float left indent with icon centered view v wrap. no list style -->
<ul class="menu">
<li>Home</li>
<li>About Me</li>
<li>My Services</li>
<li>Contact</li>
</ul>
</div>
</div>
</body>
</html>