我不確定如果我沒有記錯,但我想我讀過一次在css規則中使用>選擇器是不好的做法?有人能對這個話題有所瞭解嗎?在CSS中使用子選擇器(>)有問題嗎?
例如:
<style>
#search-form {
... whatever rules...
}
#search-form > input[type=text] {
... rules...
}
#search-form > button {
... rules ...
}
</style>
<form id="search-form">
<input type="text" placeholder="Search...">
<button>Search!</button>
</form>
['>'是一個工具(http://www.w3.org/TR/CSS2/selector.html#child-selectors) 。像任何工具一樣,如果使用不當或不正確或不準確或缺乏理解,結果可能會出乎意料。 – 2012-02-19 23:44:44