2
8

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 5 years have passed since last update.

CSSで見出しをデザインする

Last updated at Posted at 2017-03-13

見出しデザイン一覧

01.テキストに下線

コンポーネント_見出し_下線.png

qiita.rb
<div class="headline">
  <h2 class="headline__title">タイトル</h2>
</div>
qiita.rb
.headline {
    background-color: #fff;
    clear: both;
    margin-bottom:3rem;
    overflow: hidden;
    padding: 3rem;
}
.headline__title{
    color:#24936E;
    border-bottom: 1px solid #434343;
    font-size: 3rem;
    padding:0 2rem 2rem;
}

ファイル保管場所:GitHub

02.テキストに下線(2色)

コンポーネント_見出し_下線2色.png

qiita.rb
<div class="headline">
  <h2 class="headline__title">タイトル</h2>
</div>
qiita.rb
.headline__title{
    border-bottom: solid 3px #7E807B;
    padding-bottom: 1rem;
    position: relative;
}
.headline__title:after{
    border-bottom: solid 3px #333333;
    bottom: -3px;
    content: " ";
    display: block;
    position: absolute;
    width: 20%;
}

ファイル保管場所:GitHub

03.アイコン付き

アイコン付き.png

qiita.rb
<!-- アイコンフォント読込 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">

<!-- 見出し -->
<h2 class="headline">タイトル</h2>
qiita.rb
.headline{
    background: #f1f8ff;
    border-left: solid 2em #009ABF;
    padding: 0.3em 0.5em;
    position: relative;
}
.headline:before{
    color:#fff;
    content: "\f021";
    font-family: FontAwesome;
    font-weight: normal;
    left: -1.45em;
    position: absolute;
    padding: 0em;
    -moz-transform: translateY(-50%);
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
    top: 50%;
}

ファイル保管場所:GitHub

使用するアイコンを変更する場合は、CSSの"content"の値を変更。
Font Awesomeのページの"unicode"から値は取得可能。
font_refresh.png

アイコンフォントを使用した見出しは他にもこちらで色々なサンプルあり

参考

CSSで見出しデザインをするときに参考になるサイト

2
8
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
2
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?