LoginSignup
3
1

More than 5 years have passed since last update.

CSSで三角をつくる

Last updated at Posted at 2018-02-23

CSSでボックスのかどっこに三角表示させたいとの要望があったのでメモです。

HTML

<div class="sankaku_block">
  <div class="sankaku_border"><div class="sankaku"></div></div>
</div>

CSS

.sankaku_block {
  border: 1px solid #000;
  width: 300px;
  height: 300px;
  position: relative;
}
.sankaku_border {
  border-left: 1px solid #000;
  border-bottom: 1px solid #000;
  position: absolute;
  right: 0;
  top: 0;

}
.sankaku{
  width: 0;
  height: 0;
  border: 10px solid transparent;
  border-top: 10px solid #00f;
  border-right: 10px solid #00f;
  border-bottom: 10px solid #f00;
  border-left: 10px solid #f00;
}

スクリーンショット 2017-09-26 14.59.21.png

3
1
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
3
1