-1
下面是一些XML ...設置寬度僅考慮其元素的命名
<style type="text/css">
.center:nth-of-type(1):firstchild {width: 100% !important;}
</style>
<div class="center">
<subjective_element_name>//This element's width should be set
<subjective_element_name>//This element is NOT a direct child, not set
</subjective_element_name>
</subjective_element_name>
</div>
我想迫使第一元素是.center
元素的孩子有一個width: 100%;
宣言。我不希望它在任何其他元素上出現超過一次(.center
選擇器只存在一次)。這意味着選擇器只能匹配上面的subjective_element_name
元素。
請使用您問題上的編輯鏈接添加其他信息。後回答按鈕應該只用於問題的完整答案。 – nietonfir
@nietonfir:如何「找出答案:找到解決方案」並非完整答案?提問者沒有權利回答他們自己的問題嗎? – BoltClock
我的回答對我自己來說工作得很好,所以我發佈了它,Kei的工作也是如此,所以我接受他,因爲他在我之前發佈。 – John