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 1 year has passed since last update.

CSSで見出しの左右に\斜線/を付ける

Last updated at Posted at 2023-03-01

良く見出しに \ゆっくりしていってね/ みたいな飾りを付けることがあります。

ただ、これを文字でやると、角度が変えられないのでちょっと微妙です。
またアクセシビリティ的にも文字で書かれていると、スクリーンリーダーで読み上げられてしまうので、あまりよろしくありません。

CSSで解決してみましょう。

<h2>ゆっくりしていってね</h2>
h2 {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  line-height: 1;
  color: #f11f8d;
}

h2::before,h2::after {
  width: 1px;
  height: 28px;
  content: "";
  background-color: #f11f8d;
}

h2::before {
  margin-right: 0.5em;
  transform: rotate(-30deg);
}

h2::after {
  margin-left: 0.5em;
  transform: rotate(30deg);
}

JSBin
https://output.jsbin.com/cixeyof

意外に簡単ですね。

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?