0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

cssを使って、レターマークを作るには

Posted at

ゴール / CSS・HTMLを使ってレターマークを作る

スクリーンショット 2021-03-10 231348.png

このレターマークをHTML・CSSで作ります。

HTMLをかく

html
<div class="letter">
  <div class="btn-letter"></div>
</div>

・親要素=letterクラス
・子要素=btn-letterクラス
ということは最低限把握しておきましょう。

CSSをかく

css
.btn-letter {
 background-color: #fff;
 border-top: solid 3px blue;
 border-left: solid 3px red;
 border-bottom:  solid 3px orange;
 border-right: solid 3px orchid;
 height: 400px;
 position: relative;
}
.btn-letter::after,
.btn-letter::before {
  content: "";
  position: absolute;
  width: 100px; /* 幅指定 */
  height: 70px; /* 高さ指定 */
}
.btn-letter::before {
  left: 200px;  /*赤線から右に200px*/
  top: 150px;  /*青線から下に150px*/
  border: solid 3px black;
}

スクリーンショット 2021-03-10 225252.png

これでレターマークの枠が出来ました。
次は、この枠内にブイの字を書いていきましょう!

css
.btn-letter::after {
  top: 150px;
  left: 200px;
  border-bottom: solid 3px orange;
  border-top: solid 3px blue;
  border-left: solid 3px red;
  border-right: solid 3px orchid;
  transform: rotate(45deg); /*45度の回転角度をつける*/
}

どこの線を使えばいいかわかりやすいように上下左右全てにおいてtransform: rotate(45deg);を付けました。
早速見てみましょう。

スクリーンショット 2021-03-10 225813.png

ブイの字を作るには、
・オレンジの線(border-bottom)
・ピンクの線(border-right)
を使えばよさそうですね!

では、このcss(.btn-letter::after)を書き換えてブイの字を作りましょう!

css
.btn-letter::after {
  top: 117px;
  left: 216px;
  width: 70px;
  height: 70px;
  border-bottom: solid 3px orange;
  border-right: solid 3px orchid;
  transform: rotate(45deg); /*45度の回転角度をつける*/
}

topとleftを微調整して....

スクリーンショット 2021-03-10 231112.png

できました!!
是非皆さんもチャレンジしてみて下さい!

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?