3
I try to line up in all ways with text-align: center;
but none of it works and when I spacing with left
the sub-menus are misaligned from the menu!
* {
margin: 0;
padding: 0;
}
.menu {
width: 100%;
height: 60px;
background-color: black;
font-family: Roboto;
box-shadow: 0px 0px 100px 20px;
}
.menu ul {
list-style: none;
position: relative;
}
.menu ul li {
width: 150px;
padding: 0px 10px;
float: left;
line-height: 30px;
}
.menu ul li a {
text-align: center;
font-size: 19px;
}
.menu a {
padding: 15px;
display: block;
text-align: center;
text-decoration: none;
color: #4d4d4d;
}
.menu ul ul {
background-color: black;
position: absolute;
visibility: hidden;
}
.menu ul ul li {
float: none;
border-bottom: solid 1px #262626;
}
.menu ul li:hover ul {
visibility: visible;
}
.menu a:hover {
transition: all 0.4s ease;
color: white;
text-shadow: 3px 3px 20px;
}
.menu ul ul li {
background-color: #1a1a1a;
}
.menu ul ul a {
font-size: 17px;
}
.menu ul ul li a:hover ul ul ul {
visibility: visible;
}
<body>
<nav class="menu">
<ul>
<li><a href="#">5</a></li>
<li><a href="#">4</a>
<ul>
<li><a href="#">1</a></li>
</ul>
</li>
<li><a href="#">3</a>
<ul>
<li><a href="#">3</a></li>
<li><a href="#">2</a></li>
<li><a href="#">1</a></li>
</ul>
</li>
<li><a href="#">2</a>
<ul>
<li><a href="#">5</a></li>
<li><a href="#">4</a></li>
<li><a href="#">3</a></li>
<li><a href="#">2</a></li>
<li><a href="#">1</a></li>
</ul>
</li>
<li><a href="#">1</a>
<ul>
<li><a href="#">5</a></li>
<li><a href="#">4</a></li>
<li><a href="#">3</a></li>
<li><a href="#">2</a></li>
<li><a href="#">1</a></li>
</ul>
</li>
</ul>
</nav>
</body>
Sorry sam, but I guess I didn’t specify well what I really wanted to do, I wanted to align the menu to the center of the screen without the sub-menus getting into confusion and misalignment!
– Carlos Alberto
See if that’s it now, buddy.
– Sam