[CSS]属性セレクタと擬似要素を設定するサンプル

2021年9月9日

構文
div[class=クラス名]::before{cssコード}
div[class=クラス名]::after{cssコード}
属性セレクタ::擬似要素

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<style>
/* div[class=セレクタ名]::beforeの定義*/
div[class="cftA"]::before {
content:" start ";
color:red;
background-color:skyblue;
}
/* div[class=セレクタ名]::afterの定義*/
div[class="cftB"]::after {
content:" end ";
color:gold;
background-color:skyblue;
}
</style>
<!--クラスcftAを使用 -->
<div class="cftA">擬似要素の::beforeを指定</div>
<!--クラスcftBを使用 -->
<div class="cftB">擬似要素の::afterを指定</div>
<style> /* div[class=セレクタ名]::beforeの定義*/ div[class="cftA"]::before { content:" start "; color:red; background-color:skyblue; } /* div[class=セレクタ名]::afterの定義*/ div[class="cftB"]::after { content:" end "; color:gold; background-color:skyblue; } </style> <!--クラスcftAを使用 --> <div class="cftA">擬似要素の::beforeを指定</div> <!--クラスcftBを使用 --> <div class="cftB">擬似要素の::afterを指定</div>
<style>
/* div[class=セレクタ名]::beforeの定義*/
div[class="cftA"]::before {
      content:" start  "; 
    color:red;
    background-color:skyblue;
}
/* div[class=セレクタ名]::afterの定義*/
div[class="cftB"]::after {
      content:" end  "; 
    color:gold;
    background-color:skyblue;
}
</style>

<!--クラスcftAを使用 -->
<div class="cftA">擬似要素の::beforeを指定</div>
<!--クラスcftBを使用 -->
<div class="cftB">擬似要素の::afterを指定</div>

 

CSS

Posted by arkgame