2016-04-08 29 views
-1

我已经设置了保证金权在我的引导标签是这样的:如何改变最后一个标签的CSS在引导标签

.nav-tabs > li > a { 
    margin-right: 30px; 
} 

不过,我想保证金右设为零,最后选项卡上。 IE浏览器。如果我有三个选项卡,前两个选项卡的右边距为30,最后一个选项卡的右边距为0.

有关如何操作的任何想法?明信片上的答案...

回答

2

您可以使用CSS :last-of-type pseudoselector来处理这个,因为它会指定为预期给定类型相匹配的最后一个元素:

.nav-tabs > li:last-of-type > a { 
    margin-right: 0; 
    /* Define any other styles here */ 
} 

您可以see a working example of this here和(使用颜色来帮助下面演示指示定位):

enter image description here

1

你可以这样做

.nav-tabs > li:last-of-type > a { 
    margin-right: 0; 
} 
1

你可以试试这个

.nav-tabs > li:last-child > a { 
    margin-right: 0px; 
} 
1

如果HTML是这样的:

<ul class="nav-tabs"> 
    <li><a href="#">link</a></li> 
    <li><a href="#">link</a></li> 
    <li><a href="#">link</a></li> 
</ul> 

你可以选择最后的li,并给它或其a孩子一个保证金 - 右:

.nav-tabs > li:last-of-type { 
    margin-right: 0; 
} 
/*OR*/ 
.nav-tabs > li:last-of-type > a { 
    margin-right: 0; 
} 
相关问题