0
0

More than 3 years have passed since last update.

CSS~擬似要素と擬似クラス~

Last updated at Posted at 2021-04-01

今回はCSSで使用する、疑似要素について学習していきます。

疑似要素とは

指定している要素の特定の部分にスタイル付けすることができます。

index.html
<h1><span></span>いうえお</h1>
style.css
h1 {
 color: red;
}

span {
 color: blue;
}

疑似クラス

HTMLをいじることなく要素を作ることができます!

index.html
<h1>あいうえお</h1>
style.css
h1::before {
 content: 'いぇあ!いぇあ!';
}

あいうえおの直前にいぇあ!が出ます。
疑似クラスには他にも、active,hover,checkedなどがあります。

疑似クラスを使うメリット

①HTMLの文章構造を変えることなく見かけ上の要素を追加することができる
②あとから追加することができる。
③コピペされたくないとき(?)
となります。

具体的な使い方は次の記事で触れていきたいと思います!!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0