CSS 要素名[属性名$=”値”]で指定の属性の値で終わる要素にCSSを適用する
環境
Google Chrome 106.0.5249.119
Windows 10 Home 64bit
構文
要素名[属性名$="値"]
指定の属性の値で終わる要素にCSSを適用します。
テキストボックスのname属性の値が含まれています
input[name$="値"]
name属性は、指定の値で終わっているのでCSSが適用されます。
使用例
<!DOCTYPE html>
<html>
<head>
<style>
/*指定の属性の値で終わる*/
input[name$="rk"]{
color:red;
background-color:yellow
}
</style>
</head>
<body>
<input type="text" name="cirk" value="東京" maxlength="15">
<p><input type="text" name="arkga" value="大阪" maxlength="15"></p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
/*指定の属性の値で終わる*/
input[name$="rk"]{
color:red;
background-color:yellow
}
</style>
</head>
<body>
<input type="text" name="cirk" value="東京" maxlength="15">
<p><input type="text" name="arkga" value="大阪" maxlength="15"></p>
</body>
</html>
<!DOCTYPE html> <html> <head> <style> /*指定の属性の値で終わる*/ input[name$="rk"]{ color:red; background-color:yellow } </style> </head> <body> <input type="text" name="cirk" value="東京" maxlength="15"> <p><input type="text" name="arkga" value="大阪" maxlength="15"></p> </body> </html>
結果
文字「東京」行の文字色(red)と背景色(yellow)をします