0

i've been designing an menu for my website. i've reached an issue with converting in to html/css. The idea is to have an divider line on each side of the text and on mouse over the navigation lines will disappear and show the hover image. but whatever i do the line is still there on one of the sides.

An image of my navigation menu

nav-lnie.png: is just only the line hover.png is the whole mouseover image

does anybody have a solution or an explanation how to do this?

css looks like this:

.navigation{
width:370px; 
float:left;
position: absolute;
left: 300px;
background:url(../images/nav-lnie.png) repeat-y 0 0;
padding:0 0 0 4px; font-size:14px;
font-family:Arial, Helvetica, sans-serif;
color:#fff; text-shadow:1px 1px 1px #333
}

.navigation ul li{background:url(../images/nav-lnie.png) repeat-y right 0;
margin:0 2px 0 0; 
}

.navigation ul li a{
display:block;
float:left;
width:90px;
height:38px;
padding:70px 0 0 0;
text-align:center;
color:#fff;
text-decoration:none;
}

.navigation ul li a:hover{
background:url(../images/hover.png) repeat-x;
}

And html like this:

<div class="navigation">
    <ul>
       <li><a href="index.php">Videos</a></li>
       <li><a href="top.php">Top Videos</a></li>
       <li><a href="upload_video.php">Upload</a></li>
       <li><a href="faq.php">FAQ</a></li>
    </ul>
</div>
4

1 回答 1

1

这很可能是由于您在此处拥有的保证金代码:

.navigation ul li{
    background:url(../images/nav-lnie.png) repeat-y right 0;
    margin:0 2px 0 0; 
}

由于每个菜单项的右侧都有 2px 的边距,因此如果您将鼠标悬停在下一个元素上,左边距不会被隐藏。如果真的不需要边距,您可以将其删除,并且它应该可以正常工作,因为有足够的空间。如果有必要,然后在悬停命令上,您可以更改元素上的间距:

.navigation ul li a:hover{
    background:url(../images/hover.png) repeat-x;
    margin-left: -2px;
    padding-left: 2px;
}

当然,解决问题是一个粗略的技巧。两端的间距也可以调整。

于 2013-11-07T20:52:44.487 回答