运行 ❯
获取您的
自己
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> /* Select h2 elements that are immediately followed by a p element */ h2:has(+ p) { color: gray; background-color: gold; border: 2px dotted red; } </style> </head> <body> <h1>Demo of :has()</h1> <p>A paragraph</p> <h1>Heading 1</h1> <h2>Heading 2</h2> <p>A paragraph</p> <h1>Heading 1</h1> <h2>Heading 2</h2> <h3>Heading 3</h3> </body> </html>