【CSS】プラスとマイナスをつくる

デザオ
プラスってCSSで作れますかー?
デザコト
作れますよー

プラス

コードを見る(HTML・CSS)

HTML

<div class="plus"></div>

CSS

/* ---------- 01 プラス ---------- */
.plus {
  position: relative;
  width: 30px;
  height: 30px;
  margin: 0 5px;
}
.plus:before, .plus:after {
  display: block;
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  background-color: #2b2a27;
  border-radius: 10px;
}
.plus:before {
  width: 5px;
  height: 30px;
}
.plus:after {
  width: 30px;
  height: 5px;
}

マイナス

コードを見る(HTML・CSS)

HTML

<div class="minus"></div>

CSS

/* ---------- 02 マイナス ---------- */
.minus {
  position: relative;
  width: 30px;
  height: 30px;
  margin: 0 5px;
}
.minus:after {
  display: block;
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  background-color: #2b2a27;
  border-radius: 10px;
  width: 30px;
  height: 5px;
}
デザオ
わーい
デザコト
疑似要素を使えば簡単ですよー

ふたりの小言

デザコトauthor

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