Bootstrap tabs transparent underline

痴心易碎 提交于 2019-12-11 02:53:19

问题


I'm trying to make the underline from the active / hovered tab transparent. But I didn't get it working. Anyone knows how to do this?

Screenshot: http://i.imgur.com/m6ogRjB.png I want the red marked white line removed. Setting blue border bottom color isn't the correct solution because I need it transparent/removed.

JSFiddle: http://jsfiddle.net/mULUv/6/

    border-color: #fff #fff transparent;

I guess I need something to do here. But still don't get it working like I want.


回答1:


Since you can only cover up borders in css, and since you do not want to set a blue color to overlap one of your borders, the only remaining (and quite tricky) way of achieving the effect you are looking for is to "build" the borders block by block.

The idea is to remove the bottom border from the ul container bar and add fillers between the tabs and after them that would have a bottom border. Then, the tabs which are not hovered nor active will have a bottom border displayed closing the gaps between fillers. Hovering or activating will cause the tab to lose the bottom border and to gain a right, left and top border. Using a custom css class such as your .tab-advanced this can be done safely without overwriting the built-in BootStrap classes.

Here is a working demo.

The html code to add the fillers changes the list to:

<ul class="nav nav-tabs tabs-advanced">
    <li class="active"><a href="#1" data-toggle="tab">1</a></li>
    <li class="in-between-filler"></li>
    <li><a href="#2" data-toggle="tab">2</a></li>
    <li class="in-between-filler"></li>
    <li><a href="#3" data-toggle="tab">3</a></li>
    <li class="filler"></li>
</ul>

and the corresponding additional css is:

.tabs-advanced {
    display: table;
    border: none;
}

.tabs-advanced > li{
    display: table-cell;
    float: none;
}

.tabs-advanced > li > a{
    margin-right: 0;
    border-bottom-style: none;
}

.tabs-advanced > li:not(.active):not(:hover) {
    border-bottom: 1px solid #ddd;
}

.tabs-advanced > li.filler{
    width: 100%;
    border-bottom: 1px solid #ddd;
}

.tabs-advanced > li.in-between-filler{
    min-width: 2px;
    border-bottom: 1px solid #ddd;
}



回答2:


You could either do...

border: none;

or

border: 1px solid transparent;

(if you want a 1px line there still)



来源:https://stackoverflow.com/questions/18173386/bootstrap-tabs-transparent-underline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!