CSSの擬似要素を使った見出しデザイン

このブログの見出しはシンプルなんですが、CSSの「:before」や「:after」など擬似要素を使えば色々と装飾ができますので今回は8つのサンプルを紹介します。

headline13.png

HTMLHh4使

:before:after使:before:afterIE7



8

1. 1

headline1.png
:aftertransparent
headline10.png
100px

h4position: relative;h4top: 100%;h4
h4 {
  position: relative;
  color: #fff;
  background: #777;
  font-size: 20px;
  line-height: 1;
  text-shadow: 1px 1px 1px #000;
  border :1px solid #777;
  margin: 30px -10px 10px -10px;
  padding: 15px 5px 12px 10px;
  border-radius: 3px;
}
h4:after {
  content: "";
  position: absolute;
  top: 100%;
  left: 30px;
  height: 0;
  width: 0;
  border: 10px solid transparent;
  border-top: 10px solid #777;
}

2. 2

headline1.png

h4 {
  position: relative;
  color: #111;
  background: #fff;
  font-size: 20px;
  line-height: 1;
  border :2px solid #555;
  margin: 30px -10px 10px -10px;
  padding: 15px 5px 12px 10px;
  border-radius: 3px;
}
h4:after,h4:before {
  content: "";
  position: absolute;
  top: 100%;
  height: 0;
  width: 0;
}
h4:after {
  left: 33px;
  border: 11px solid transparent;
  border-top: 11px solid #fff;
}
h4:before {
  left: 30px;
  border: 14px solid transparent;
  border-top: 14px solid #555;
}

3. 1

headline1.png

headline10.png
padding30pxh4margin-40px10px10px5px
h4 {
  position: relative;
  color: #fff;
  background: #555;
  font-size: 20px;
  line-height: 1;
  margin: 30px -40px 10px -40px;
  padding: 15px 5px 10px 40px;
  box-shadow: 0 1px 3px #777;
}
h4:after,h4:before {
  content: "";
  position: absolute;
  top: 100%;
  height: 0;
  width: 0;
  border: 5px solid transparent;
  border-top: 5px solid #333;
}
h4:after {
  left: 0;
  border-right: 5px solid #333;
}
h4:before {
  right: 0;
  border-left: 5px solid #333;
}

4. 2

headline1.png
使
h4 {
  position: relative;
  color: #111;
  background: #ccc;
  background-image: -webkit-linear-gradient(#ddd, #bbb);
  background-image: -moz-linear-gradient(#ddd, #bbb);
  background-image: -o-linear-gradient(#ddd, #bbb);
  background-image: -ms-linear-gradient(#ddd, #bbb);
  background-image: linear-gradient(#ddd, #bbb);
  font-size: 20px;
  line-height: 1;
  margin: 30px -40px 10px -40px;
  padding: 15px 5px 10px 40px;
}
h4:after,h4:before {
  content: "";
  position: absolute;
  top: 100%;
  height: 0;
  width: 0;
  border: 5px solid transparent;
  border-top: 5px solid #777;
}
h4:after {
  left: 0;
  border-right: 5px solid #777;
}
h4:before {
  right: 0;
  border-left: 5px solid #777;
}

5. 1

headline1.png

headline11.png
transparent
h4 {
  position: relative;
  color: #111;
  background: #ccc;
  font-size: 20px;
  line-height: 1;
  margin: 30px 20px 10px -10px;
  padding: 14px 5px 10px 50px;
  border-radius: 22px 0 0 22px;
}
h4:before {
  content: "";
  position: absolute;
  background: #eee;
  top: 50%;
  left: 14px;
  margin-top :-10px;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  box-shadow: 1px 1px 1px #777 inset;
}
h4:after {
  content: "";
  position: absolute;
  top: 0;
  right: -22px;
  height: 0;
  width: 0;
  border: 22px solid #ccc;
  border-right-color: transparent;
}

6. 2

headline1.png

h4 {
  position: relative;
  color: #111;
  background: #ccc;
  font-size: 20px;
  line-height: 1;
  margin: 30px 0 10px 0;
  padding: 14px 5px 10px 40px;
  box-shadow: 0 1px 3px #777;
  border-radius: 0 10px 10px 0;
}
h4:before {
  content: "";
  position: absolute;
  background: #999;
  top: 50%;
  left: -20px;
  margin-top :-22px;
  height: 44px;
  width: 44px;
  box-shadow: 1px 1px 1px #777;
  border-radius: 50%;
}
h4:after {
  content: "";
  position: absolute;
  background:#777;
  top: 50%;
  left: -15px;
  margin-top:-15px;
  height: 24px;
  width: 24px;
  border-radius: 50%;
}

7. 

headline1.png
使


headline12.png

h4 {
  position: relative;
  font-size: 20px;
  line-height: 1;
  margin:30px -30px 10px -30px;
  padding: 15px 5px 10px 20px;
  border-left: 10px solid #777;
}
h4:after {
  content: "";
  position: absolute;
  bottom: 0px;
  left: 0;
  height: 0;
  width: 100%;
  border-bottom: 1px dashed #555;
}

8. 

headline1.png
2rotateIE8
h4 {
  position: relative;
  color: #111;
  font-size: 20px;
  line-height: 1;
  margin: 30px 0 0 0;
  padding: 14px 5px 10px 10px;
}
h4:before {
  content: "";
  position: absolute;
  background: #999;
  top: 0;
  left: -5px;
  height: 12px;
  width: 12px;
  -moz-transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}
h4:after {
  content: "";
  position: absolute;
  background:#777;
  top: 15px;
  left: -10px;
  height: 8px;
  width: 8px;
  -moz-transform: rotate(15deg);
  -webkit-transform: rotate(15deg);
  -o-transform: rotate(15deg);
  -ms-transform: rotate(15deg);
  transform: rotate(15deg);
}

8:before:after使使
フィードやTwitterで最新情報をチェック
follow us in feedly
この記事に付いているタグの最新記事一覧
loading...
コメント
CSS
【2013/02/01 22:13】 | あれはんどろ #bCpyViaU | [edit]
あれはんどろ さん

コメントありがとうございます。
擬似要素は使い方によって色々できますので面白いです。

またお立ち寄りください~!
【2013/02/02 03:57】 | 管理人 #E2ywrYdA | [edit]









※コメントはご意見ご感想や間違いのご指摘等にしていただけますようお願いいたします。コメントを確認する時間がなく、技術的なご質問をいただいても答えできません。申し訳ございませんがご理解のほどお願いいたします。

Recent Entry

Popular Entry

  • このエントリーをはてなブックマークに追加