css3 - 用偽類選擇移除自己的其他兄弟級
問題描述
類似p:hover::before,因為是四個子級,所以想選取排除自己的其他兄弟級
問題解答
回答1:沒看到代碼,不過感覺應該是從p下手處理而不是偽類。
回答2:$('p').siblings();
回答3:用普通兄弟選擇器:“~”
比如HTML:
<p class='brother-selector'> <h2>標題0</h2> <p>咳咳,內容。</p> <h2>標題1</h2> <h2>標題2</h2> </p>
CSS這樣寫:
p + h2{color:red; } p ~ h2{font-weight:700; }
結果如下:
<ul> <li>item1</li> <li>item2</li> <li>item3</li> <li>item4</li> <li>item5</li> <li>item6</li></ul>*{ padding:0; margin:0}ul,li{ list-style: none;}li{ padding:10px; margin:10px; border:3px solid #000; font-weight:bold}li:first-child{ color:#f30}li:last-child{ border-color:red}li:nth-child(2){ background: orange;}li:nth-child(3n){ background:#1FD39E;/*3n就是3的倍數都加這個樣式*/}
demo
相關文章:
1. css3 - 手機網頁中用css寫1px的描邊,為什么需要加一句overflow:hidden才能真正顯示1px?2. mysql - 一個表和多個表是多對多的關系,該怎么設計3. Mysql && Redis 并發問題4. javascript - node服務端渲染的困惑5. php - 第三方支付平臺在很短時間內多次異步通知,訂單多次確認收款6. javascript - 百度echarts series數據更新問題7. python - type函數問題8. css3 - css before 中文亂碼?9. mysql新建字段時 timestamp NOT NULL DEFAULT ’0000-00-00 00:00:00’ 報錯10. css - 求推薦幾款好用的移動端頁面布局調試工具呢?
