使用 CSS 選中包含單詞“教程”的 alt 屬性的所有元素
使用 [attribute ~= "value"] 選擇器選擇帶有屬性值包含特定單詞的元素,使用 CSS。
你可以嘗試執行以下程式碼來實現 [attribute ~= "value"] 選擇器。此處,我們搜尋的單詞為“教程”,
示例
<!DOCTYPE html>
<html>
<head>
<style>
[alt ~= Tutorials] {
border: 5px solid orange;
border-radius: 5px;
}
</style>
</head>
<body>
<img src = "https://tutorialspoint.tw/videotutorials/images/tutor_connect_home.jpg" height = "200" width = "200" alt = "Tutor Connect">
<img src = "https://tutorialspoint.tw/videotutorials/images/tutorial_library_home.jpg" height = "200" width = "200" alt = "Tutorials Library">
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP