选择前面有 CSS 元素的每个元素
原创
使用元素 ~ 元素选择器选择
- 元素,前面是
元素。您可以尝试运行以下代码来实现此示例
示例
实时演示
<!DOCTYPE html> <html> <head> <style> p~ul { color: white; background-color: blue; } </style> </head> <body> <h1>Demo Website</h1> <h2>Fruits</h2> <div> <p>Vegetables are good for health.</p> <ul> <li>Spinach</li> <li>Onion</li> <li>Capsicum</li> </ul> </div> <p>Fruits are good for health.</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p> <ul> <li>Apple</li> <li>Orange</li> <li>Kiwi</li> </ul> </body> </html>
以上就是选择前面有 CSS 元素的每个元素的详细内容,更多请关注IT视界其它相关文章!
上一篇:如何用 CSS 使表格居中? 下一篇:CSS 中哪个属性指定元素的右填充?