1

如何在导航中突出显示我的活动标签?几个小时以来,我一直在尝试不同的方式,但没有一个能正常工作。我知道有一些方法可以做到这一点,比如使用 active、selected 等,但我就是做错了。请帮忙。

这是我的 css 文件中的代码,在选项卡控件上有一些设置。

/* Tab Control */
#tabs ul 
{
    padding: 0px;
    margin: 0px;
    margin-bottom: 10px;
    margin-left: 270px;
    list-style-type: none;
    }
#tabs ul li 
{
    display: outline-block;
    clear: none;
    float: left;
    height: 24px;
}
#tabs ul li a {
    position: relative;
    margin-top: 16px;
    display: block;
    width: 130px;
    color: #6d6e71;
    text-decoration: none;
} 
#tabs ul li a:hover {
    text-decoration: underline;
    color: #eb8c00;
}
#tabs #Content_Area 
{
    margin-left: 270px;
    padding: 0 15px;
    clear:both;
    overflow:hidden;
    line-height:19px;
    position: relative;
    top: 20px;
    z-index: 5;
    height: 150px;
    overflow: hidden;
    }

还有我的html代码:

<div id="tabs">
    <ul>
        <li id="li_tab1" onclick="tab('tab1')"><a>Tab 1</a></li>
        <li id="li_tab2" onclick="tab('tab2')"><a>Tab 2</a></li>
    </ul>
    <div id="Content_Area">
        <div id="tab1">
            <p>This is the text for tab 1.</p>
        </div>
        <div id="tab2" style="display: none;">
            <p>This is the text for tab 2.</p>
        </div>
    </div>
</div>
4

1 回答 1

0

如果您没有在锚点单击上刷新页面,那么您可以使用 jquery 突出显示选项卡,这里是代码:

$('ul li').click(function(e){
e.preventDefault();
$(this).children().css('color','red');
$(this).siblings().children().css('color','black');
});

和 jsFiddle 示例:http: //jsfiddle.net/338qH/

于 2013-06-13T08:34:59.697 回答