我已經設置了保證金權在我的引導標籤是這樣的:如何改變最後一個標籤的CSS在引導標籤
.nav-tabs > li > a {
margin-right: 30px;
}
不過,我想保證金右設爲零,最後選項卡上。 IE瀏覽器。如果我有三個選項卡,前兩個選項卡的右邊距爲30,最後一個選項卡的右邊距爲0.
有關如何操作的任何想法?明信片上的答案...
我已經設置了保證金權在我的引導標籤是這樣的:如何改變最後一個標籤的CSS在引導標籤
.nav-tabs > li > a {
margin-right: 30px;
}
不過,我想保證金右設爲零,最後選項卡上。 IE瀏覽器。如果我有三個選項卡,前兩個選項卡的右邊距爲30,最後一個選項卡的右邊距爲0.
有關如何操作的任何想法?明信片上的答案...
您可以使用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和(使用顏色來幫助下面演示指示定位):
你可以這樣做
.nav-tabs > li:last-of-type > a {
margin-right: 0;
}
你可以試試這個
.nav-tabs > li:last-child > a {
margin-right: 0px;
}
如果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;
}