div~div 和 div:not(:first-of-type) 的區別?
兩者在匹配元素方面相同。讓我們來看一個例子
<section> <div></div> <!-- div:first-child or div:first-of-type --> <div></div> <!-- div+div or div~div or div:nth-of-type(2) --> <p></p> <div></div> <!-- div+p+div or div~div or div:nth-of-type(3), but not div+div --> </section> <section> <h1></h1> <!-- h1:first-child --> <div></div> <!-- div:first-of-type or div:nth-child(2) --> <div></div> <!-- div~div or div:nth-of-type(2) or div:nth-child(3) --> </section>
如果您有 CSS 規則,並且兩個選擇器都匹配相同的元素,那麼由於 :first-of-type 偽類,您的 div:not(:first-of-type) 將具有優先順序。
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP