【CSS】吹き出しをつくる

【CSS】吹き出しをつくる
きのこさん
ふきだしー
きのこさん
ふきだしー

吹き出し(下)

See the Pen CSSだけで、ふきだしをつくる by 125naroom (@125naroom) on CodePen.

HTML

<div class="arrow_box">ふきだしです。</div>

CSS

.arrow_box {
  position: relative;
  display: inline-block;
  background: #fff;
  border: 4px solid #333;
  padding: 30px;
  margin: 0;
}
.arrow_box:after, .arrow_box:before {
  content: "";
  height: 0;
  width: 0;
  position: absolute;
  top: 100%;
  left: 50%;
  border: solid transparent;
}
.arrow_box:after {
  border-color: rgba(255, 255, 255, 0);
  border-top-color: #fff;
  border-width: 14px;
  margin-left: -14px;
}
.arrow_box:before {
  border-color: rgba(51, 51, 51, 0);
  border-top-color: #333;
  border-width: 20px;
  margin-left: -20px;
}

吹き出し(上)

See the Pen CSSだけで、ふきだし(上)をつくる by 125naroom (@125naroom) on CodePen.

HTML

<div class="arrow_box">ふきだしです。</div>

CSS

.arrow_box {
  position: relative;
  display: inline-block;
  background: #fff;
  border: 4px solid #333;
  padding: 30px;
  margin: 0;
}
.arrow_box:after, .arrow_box:before {
  content: "";
  height: 0;
  width: 0;
  position: absolute;
  bottom: 100%;
  left: 50%;
  border: solid transparent;
}
.arrow_box:after {
  border-color: rgba(255, 255, 255, 0);
  border-bottom-color: #fff;
  border-width: 14px;
  margin-left: -14px;
}
.arrow_box:before {
  border-color: rgba(51, 51, 51, 0);
  border-bottom-color: #333;
  border-width: 20px;
  margin-left: -20px;
}

吹き出し(左)

See the Pen CSSだけで、ふきだし(左)をつくる by 125naroom (@125naroom) on CodePen.

HTML

<div class="arrow_box">ふきだしです。</div>

CSS

.arrow_box {
  position: relative;
  display: inline-block;
  background: #fff;
  border: 4px solid #333;
  padding: 30px;
  margin: 0;
}
.arrow_box:after, .arrow_box:before {
  content: "";
  height: 0;
  width: 0;
  position: absolute;
  right: 100%;
  top: 50%;
  border: solid transparent;
}
.arrow_box:after {
  border-color: rgba(255, 255, 255, 0);
  border-right-color: #fff;
  border-width: 14px;
  margin-top: -14px;
}
.arrow_box:before {
  border-color: rgba(51, 51, 51, 0);
  border-right-color: #333;
  border-width: 20px;
  margin-top: -20px;
}

吹き出し(右)

See the Pen CSSだけで、ふきだし(右)をつくる by 125naroom (@125naroom) on CodePen.

HTML

<div class="arrow_box">ふきだしです。</div>

CSS

.arrow_box {
  position: relative;
  display: inline-block;
  background: #fff;
  border: 4px solid #333;
  padding: 30px;
  margin: 0;
}
.arrow_box:after, .arrow_box:before {
  content: "";
  height: 0;
  width: 0;
  position: absolute;
  left: 100%;
  top: 50%;
  border: solid transparent;
}
.arrow_box:after {
  border-color: rgba(255, 255, 255, 0);
  border-left-color: #fff;
  border-width: 14px;
  margin-top: -14px;
}
.arrow_box:before {
  border-color: rgba(51, 51, 51, 0);
  border-left-color: #333;
  border-width: 20px;
  margin-top: -20px;
}

吹き出しをつくるのに便利なサイトさん

ベースは下記のサイトさんで作るのはいいかと思います。
仕組みがわかればオリジナルのコーディングを。

さいごに

きのこさん
ふきだしー
きのこさん
ふきだしー

関連記事

Author

デザコト

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

Googleさんの
おすすめ

5

/

3

2024

Googleさんの
おすすめ

5

/

3

2024

デザインの記事

linea株式会社
アオアシ
【jQuery】 ローディング、実装サンプル集