1. 程式人生 > >css :not的多個條件的寫法

css :not的多個條件的寫法

:not 偽類選擇器可以篩選不符合表示式的元素

例子

table tbody tr:not(:first-child):not(:last-child) td
{
     text-align: right;
}

以上程式碼可以選擇table表格中tbody部分非首個、非最後一個的tr,並設定其子元素td文字樣式居右

這裡面需要注意not的語法格式:

單個的not寫法:

/*選中非段落元素*/
:not(p)
{

}

多個not的寫法
/*選中div裡面非首個、非最後一個的中間p元素*/
div p:not(:first-child):not(:last-child){
}