主頁
CSS
CSS 組合器
Tryit: 相鄰兄弟選擇器
執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> div + p { background-color: yellow; } </style> </head> <body> <h2>Adjacent Sibling Selector</h2> <p>The + selector is used to select an element that is directly after another specific element.</p> <p>The following example selects the first p element that are placed immediately after div elements:</p> <div> <p>Paragraph 1 in the div.</p> <p>Paragraph 2 in the div.</p> </div> <p>Paragraph 3. After a div.</p> <p>Paragraph 4. After a div.</p> <div> <p>Paragraph 5 in the div.</p> <p>Paragraph 6 in the div.</p> </div> <p>Paragraph 7. After a div.</p> <p>Paragraph 8. After a div.</p> </body> </html>