本文介紹了如何選擇帶空格的班級的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
如何選擇像 class="boolean optional"
這樣的類?
How do I select a class like class="boolean optional"
?
我試過這個:
.boolean optional {CSS}
.boolean_optional {CSS}
推薦答案
正如 Zepplock 所說,這實際上是一個屬性中的兩個類:boolean
和 optional
.空格不是類名的一部分;它充當分隔符.
As Zepplock says, that's actually two classes in a single attribute: boolean
and optional
. The space is not part of a class name; it acts as the separator.
這三個選擇器都會匹配它:
These three selectors will all match it:
.boolean
.optional
.boolean.optional
最后一個選擇器只選擇這個元素,因為它有兩個類.
The last selector only picks up this element as it has both classes.
你從不在鏈接類選擇器時包含空格,甚至像這樣:
You never include a space when chaining class selectors, not even like this:
.boolean .optional
選擇 .optional
元素,這些元素包含在單獨的 .boolean
元素中.
As that selects .optional
elements that are contained within separate .boolean
elements.
這篇關于如何選擇帶空格的班級的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!