保持当前菜单项突出显示

时间:2013-11-06 18:26:31

标签: css menu

我的页面上有一个菜单设置,可以将项目加载到iframe中。它们是自定义地图,可替代默认的Google地图。我的问题是如何让当前显示的项目的菜单项保持突出显示?

<div id="right_col" class="clearfix">

            <ul>
                <li><a href="copperwood.html" target="iframe_map">Copperwood</a></li>
                <li><a href="canyoncrest.html" target="iframe_map">Canyon Crest/The Canyons</a></li>
                <li><a href="riverstone.html" target="iframe_map">Riverstone</a></li>
                <li><a href="garrystation.html" target="iframe_map">Garry Station</a></li>
                <li><a href="legacyridge.html" target="iframe_map">Legacy Ridge</a></li>
                <li><a href="https://maps.google.com/maps/ms?msa=0&amp;msid=217268423195093625679.0004cf68eb14897eb07b4&amp;ie=UTF8&amp;ll=49.69371,-112.868754&amp;spn=0.086835,0.089951&amp;t=m&amp;output=embed" target="iframe_map">Overall Lethbridge</a></li>
            </ul>

        </div>

我的CSS:

#right_col ul{
position: relative;
list-style: none;
top: -17px;
}

#right_col ul a{
text-decoration: none;
color: #000000;
display: block;
padding:10px 10px 10px 15px;
margin: 10px;
background: #eeeeee;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */
}

#right_col ul a:hover{
background: #e9b900;
text-decoration: none;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */
}

1 个答案:

答案 0 :(得分:0)

1.给第一个li标记一个类li class="active"..

2.转到你的CSS并执行此操作:

.active{
background-color:red; // example
}

3.然后打开

script `type="text/javascript"`

$('li a').click(function()
{
  $('li').removeClass('active');
  $(this).parent().addClass('active');
});


</script>