YourDirector
08-10-2011, 03:57 PM
Hey everyone,
I have a CSS dropdown menu using the following code. My only issue is, when any of the sub-headers are hovered the root title becomes left aligned. How can I ensure it stays centred while keeping all others left aligned?
Thanks:
CSS:
ul {
font-family: 'Actor', sans-serif;
font-size: 15px;
margin: 0;
padding: 0;
list-style: none;
z-index:20;
}
ul li {
display: block;
position: relative;
z-index:20;
}
li ul { display: none; }
ul li a {
clear: none;
display:block;
padding:4px;
color: #000;
text-align:center;
text-decoration:none;
font-size:15px;
font-family: 'Actor', sans-serif;
white-space: nowrap;
z-index:20;
}
ul li a:hover { background: #dc0111; text-align:center;}
li:hover ul {
display: block;
position: absolute;
z-index:20;
}
li:hover li {
float: none;
font-size: 11px;
text-align:center;
z-index:20;
}
li:hover a { background: #dc0111; color:#FFF; text-align:left;}
li:hover li a:hover { background: #fff; color:#000; text-align:left;}
Body:
<ul id="menu">
<li><a href="games.php">GAMES</a>
<ul>
<li><a href="link.com" target="_blank">Link01</a></li>
<li><a href="link.com" target="_blank">Link02</a></li>
<li><a href="link.com" target="_blank">Link03</a></li>
<li><a href="link.com" target="_blank">Link04</a></li>
<li><a href="link.com" target="_blank">Link05</a></li>
</ul>
</li>
</ul>
I have a CSS dropdown menu using the following code. My only issue is, when any of the sub-headers are hovered the root title becomes left aligned. How can I ensure it stays centred while keeping all others left aligned?
Thanks:
CSS:
ul {
font-family: 'Actor', sans-serif;
font-size: 15px;
margin: 0;
padding: 0;
list-style: none;
z-index:20;
}
ul li {
display: block;
position: relative;
z-index:20;
}
li ul { display: none; }
ul li a {
clear: none;
display:block;
padding:4px;
color: #000;
text-align:center;
text-decoration:none;
font-size:15px;
font-family: 'Actor', sans-serif;
white-space: nowrap;
z-index:20;
}
ul li a:hover { background: #dc0111; text-align:center;}
li:hover ul {
display: block;
position: absolute;
z-index:20;
}
li:hover li {
float: none;
font-size: 11px;
text-align:center;
z-index:20;
}
li:hover a { background: #dc0111; color:#FFF; text-align:left;}
li:hover li a:hover { background: #fff; color:#000; text-align:left;}
Body:
<ul id="menu">
<li><a href="games.php">GAMES</a>
<ul>
<li><a href="link.com" target="_blank">Link01</a></li>
<li><a href="link.com" target="_blank">Link02</a></li>
<li><a href="link.com" target="_blank">Link03</a></li>
<li><a href="link.com" target="_blank">Link04</a></li>
<li><a href="link.com" target="_blank">Link05</a></li>
</ul>
</li>
</ul>