使用 CSS 选择紧跟在 div 元素之后的所有元素
cssweb developmentfront end technology更新于 2024/7/23 0:12:17
使用 element+element 选择器选择位于第一个指定元素之后的元素。您可以尝试运行以下代码来实现此功能:
示例
<!DOCTYPE html>
<html>
<head>
<style>
div + p {
color: white;
background-color: blue;
}
</style>
</head>
<body>
<h1>Demo Website</h1>
<h2>Fruits</h2>
<div>
<p>This is demo text.</p>
</div>
<p>Fruits are good for health.</p>
<p>Fruits makes you healthy.</p>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

