【问题标题】:Highlight the active tab for html mvc 4突出显示 html mvc 4 的活动选项卡
【发布时间】:2013-06-13 08:10:25
【问题描述】:

如何在导航中突出显示我的活动标签?几个小时以来,我一直在尝试不同的方式,但没有一个能正常工作。我知道有一些方法可以做到这一点,比如使用 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>

【问题讨论】:

    标签: html asp.net-mvc-4 tabs navigation


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2019-10-29
      • 1970-01-01
      • 1970-01-01
      • 2019-02-22
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多