菜单悬停应在当前站点上停止

时间:2016-06-05 23:53:57

标签: html css menu hover

我希望悬停(Lavalamp-red,这是一张图片)停在用户当前所在的网站上。

如果可能,我还想更改当前网站上的悬停颜色以及字体颜色。

.column {
    margin: auto; 
    width: 30%; 
    padding: 0 2em; 
    min-height: 1%; 
    position: relative;
}

.column *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }

.container {
   height: 2%; 
   margin: 7% auto;
   width: 957px;
   text-align:justify;
}
.container>ul>li>a:hover {
     margin-bottom:20px;
}

#nav,#nav ul {
    list-style: none outside none;
    margin: auto;
    padding: 0;
}
#nav {
    background: url('menu_bg.png') no-repeat scroll 0 0 transparent;
    clear: both;
    font-size: 12px;
    height: 58px; 
    padding: 0 0 0 9px;
    position: relative;
    width: 957px; 
}
#nav ul {
    background-color: #222; 
    border:1px solid #eeb422; 
    border-radius: 0 5px 5px 5px;
    border-width: 0 1px 1px;
    box-shadow: 0 5px 5px rgba(0, 0, 0, 0.5);
    left: -9999px;
    overflow: hidden;
    position: absolute;
    top: -9999px;
    z-index: 2;

}

#nav li a {
    color: #FFFFFF;
    display: block;
    float: left;
    font-weight: normal;
    height: 30px;
    padding: 23px 20px 0;
    position: relative;
    text-decoration: none;
    text-shadow: 1px 1px 1px #000000;
}
#nav li:hover > a {
    color: #FF0000; 
}
#nav li:hover, #nav a:focus, #nav a:hover, #nav a:active {
    background: none repeat scroll 0 0 #000000;
    outline: 0 none;
}
#nav li:hover ul.subs {
    left: 0;
    top: 57px; 
    width: 180px; 

}
#nav ul li {
    background: none;
    width: 100%; 
#nav ul li a {
    float: none;
}
#nav ul li:hover > a {
    background-color: #000000; 
    color: #FF0000;


}
#lavalamp {
    background: url(lavalamp-red.png) no-repeat scroll 0 0 transparent;
    height: 16px;
    left: 13px;
    position: absolute;
    top: 0px;
    width: 64px;

}

#nav li:nth-of-type(1):hover ~ #lavalamp {
    left: 13px;
}
#nav li:nth-of-type(2):hover ~ #lavalamp {
    left: 100px;
}
#nav li:nth-of-type(3):hover ~ #lavalamp {
    left: 198px;
}
#nav li:nth-of-type(4):hover ~ #lavalamp {
    left: 295px;
}
#nav li:nth-of-type(5):hover ~ #lavalamp {
    left: 416px;
}
#nav li:nth-of-type(6):hover ~ #lavalamp {
    left: 538px;
}
<div class="container">
            <ul id="nav">
                <li><a href="#">HOME</a></li>
                <li><a href="#">Menu 1</a></li>
                <li><a href="#">Menu 2</a>
                    <ul class="subs">
                    <li><a href="#">submenu 1</a></li>
                    <li><a href="#">submenu 2</a></li>
                    <li><a href="#">submenu 3</a></li>
                    </ul>
                </li>
                <li><a href="#">Menu 3</a></li>               
                <li><a href="#">Menu 4</a></li>
                <li><a href="#">Menu 5</a></li>
                <div id="lavalamp">
                </div>
          </ul>
          </div>

0 个答案:

没有答案