【CSS】ラインの下に三角をつくる

デザオ
ラインの下に三角を作りたいのですよー
デザコト
おー、擬似要素で作ると簡単ですよー

つくる

コードを見る(HTML・CSS)

HTML

<p class="dl_name"><span>ラインの下に三角をつくる</span></p>

CSS

/* ---------- 01 ラインの下に三角 ---------- */
.dl_name {
  position: relative;
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  padding: 0 0 10px;
  margin: 0;
}
.dl_name:before {
  content: '';
  display: block;
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-right: 50px solid transparent;
  border-left: 50px solid transparent;
  border-top: 20px solid #2b2a27;
}
.dl_name:after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  width: 200px;
  height: 1px;
  background: #2b2a27;
  z-index: 1;
}

さいごに

デザオ
できましたー
デザコト
よかったですー

ふたりの小言

デザコトauthor

あ、いいな、と思うWebデザインを紹介しています。デザインの参考に。やさしいデザインが多いです。Webデザインギャラリー『デザインのこと - Web design gallery』を運営しています。