2016-08-24 55 views
0

我用這條線隱藏在選擇最後一個選項之前選擇選項,我只需要CSS:隱藏最後CSS

.form-search > select option:last-child {display:none;} 

我該怎麼做才能掩蓋前一個選項,那就是前年選項?

可以通過選擇值嗎?例如最後有55個值,最後的選項有54個值。 謝謝

+0

試'.FORM搜索>選擇選項[值= 「55」] {display:none; }' –

回答

4

您使用nth-last-child(2)

像這樣:

.form-search > select option:nth-last-child(2) { display:none; } 

你可以在這裏閱讀更多:https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-child

這在IE支持9+,鉻4+,FF 3.5+ 3.2+的Safari

+0

謝謝,我們可以用css來按值選擇嗎? – Robert

+0

是的。請在差異問題中提問,並將其作爲評論發佈在此處 –

0

嘗試

.form-search > select option[value="55"] 
{ 
    display: none; 
}