主页
CSS
CSS 组合器
试用:相邻兄弟选择器
运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
转到 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>