選擇每個前面的元素元素 CSS
元素 CSS
使用元素 ~ 元素選擇器選擇 <p> 元素前面的 <ul> 元素。你可以嘗試執行以下程式碼來實現此操作
示例
<!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>
<ul>
<li>Apple</li>
<li>Orange</li>
<li>Kiwi</li>
</ul>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP