出于某种原因,无论我点击什么链接,我的背景颜色都会返回到最左边的链接。有人知道如何让它停留在点击的链接上吗?
css
#lamp {
float:left;
margin:25px 0px 0px 90px;
clear: both;
}
.lavaLamp {
position: relative;
height: 29px; width: 400px;
background: #000000 no-repeat top;
background-image:url('http://wildfire-restaurant.com/images/lampback.png');
padding: 15px; margin: 10px 0;
overflow: hidden;
float:left;
}
/* Force the list to flow horizontally */
.lavaLamp li {
float: left;
list-style: none;
}
/* Represents the background of the highlighted menu-item. */
.lavaLamp li.back {
background: no-repeat right -30px;
width: 9px; height: 30px;
z-index: 8;
position: absolute;
}
.lavaLamp li.back .left {
background: #BD5108 no-repeat top left;
height: 30px;
margin-right: 9px;
}
/* Styles for each menu-item. */
.lavaLamp li a {
position: relative; overflow: hidden;
text-decoration: none;
text-transform: uppercase;
font: bold 14px arial;
color: #fff; outline: none;
text-align: center;
height: 30px; top: 7px;
z-index: 10; letter-spacing: 0;
float: left; display: block;
margin: auto 10px;
}jquery
<script type="text/javascript">
$(function() { $(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 })});
</script>站点http://wildfire-restaurant.com/
发布于 2010-01-04 13:02:44
您需要在子页面的当前li中添加current类。lavalamp插件运行以下代码:
curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0];它选择具有current类或第一项的li。你可以在发送到客户端之前在服务器上添加这个类,而不需要在javascript中完成。
更新
这是当您的浏览器位于'/menu/‘页面时,导航的HTML外观。请注意,带有指向Menu的链接的li是如何具有class="current"的
<ul class="lavaLamp">
<li><a href="http://wildfire-restaurant.com/">Home</a></li>
<li class="current"><a href="http://wildfire-restaurant.com/menu/">Menu</a></li>
<li><a href="http://wildfire-restaurant.com/events/">Events</a></li>
<li><a href="http://wildfire-restaurant.com/friends/">Friends</a></li>
<li><a href="http://wildfire-restaurant.com/contact/">Contact</a></li>
<li><div class="left"></div></li>
</ul>在EVENTS页面上,包含指向Events的链接的li将包含以下类:
<li class="current"><a href="http://wildfire-restaurant.com/events/">Events</a></li>等。
发布于 2010-01-04 12:58:52
如果您使用的是this扩展....
尝试将'autoreturn‘设置为true。
否则,可能会有一个选项来设置背景返回到哪个链接。在这种情况下,您必须将其设置为onClick()。
请尝试阅读文档。
此外,发布更多关于你正在使用的扩展的信息将是有益的。这不是CSS的问题。
https://stackoverflow.com/questions/1997544
复制相似问题