Keyvisual(キービジュアル / メインビジュアル)

使い方

  1. キービジュアル / メインビジュアル

画面表示

ここに商品やサービスのキャッチフレーズが入ります

ここに商品やサービスの
キャッチフレーズが入ります

HTML/CSS(Sass)

<div class="m-keyvisual">
    <div class="m-keyvisual_inner">
        <div class="m-keyvisual_title">
            <h2>ここに商品やサービスのキャッチフレーズが入ります</h2>
        </div>
    </div>
</div>

<div class="m-keyvisual m-keyvisual02">
    <div class="m-keyvisual02_inner">
        <div class="m-keyvisual02_title">
            <h2>ここに商品やサービスの<br>キャッチフレーズが入ります</h2>
        </div>
    </div>
</div>
.m-keyvisual {
  background-image: url(https://placehold.jp/2560x1136.png);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}
@media screen and (min-width: 768px) {
  .m-keyvisual {
    height: 58rem;
  }
}
@media screen and (max-width: 767px) {
  .m-keyvisual {
    height: 91rem;
  }
}
.m-keyvisual::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}
@media screen and (min-width: 768px) {
  .m-keyvisual::after {
    height: 58rem;
  }
}
@media screen and (max-width: 767px) {
  .m-keyvisual::after {
    height: 91rem;
  }
}
.m-keyvisual_inner {
  position: relative;
  height: 100%;
  margin-right: auto;
  margin-left: auto;
  max-width: 1000px;
}
.m-keyvisual_title {
  position: absolute;
  top: 50%;
  left: 0;
  padding: 40px;
  color: #fff;
  transform: translateY(-50%);
  margin-top: 0;
  margin-bottom: 0;
}
@media screen and (min-width: 768px) {
  .m-keyvisual_title {
    font-size: 3.2rem;
    line-height: 2.2;
  }
}
@media screen and (max-width: 767px) {
  .m-keyvisual_title {
    font-size: 4rem;
    left: 50%;
    width: 90%;
    padding: 15px;
    text-align: center;
    transform: translate(-50%, -50%);
  }
}
.m-keyvisual_emphasis {
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  display: inline;
  background-color: #e5c046;
}
@media screen and (min-width: 768px) {
  .m-keyvisual_emphasis {
    padding: 1rem;
    font-size: 3.2rem;
    line-height: 2.2;
  }
}
@media screen and (max-width: 767px) {
  .m-keyvisual_emphasis {
    padding: 1rem;
    font-size: 4rem;
    line-height: 2.2;
  }
}

.m-keyvisual02 {
  display: flex;
  justify-content: center;
  align-items: center;
}
.m-keyvisual02_inner {
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  word-break: break-all;
}
@media screen and (min-width: 768px) {
  .m-keyvisual02_inner {
    width: 1000px;
  }
}
.m-keyvisual02_innerTop {
  justify-content: flex-start;
}
.m-keyvisual02_innerBottom {
  justify-content: flex-end;
}
.m-keyvisual02_innerLeft {
  align-items: flex-start;
}
.m-keyvisual02_innerRight {
  align-items: flex-end;
}
.m-keyvisual02_title {
  display: flex;
}
@media screen and (min-width: 768px) {
  .m-keyvisual02_title {
    font-size: 3.2rem;
    line-height: 2.2;
  }
}
@media screen and (max-width: 767px) {
  .m-keyvisual02_title {
    font-size: 4rem;
    line-height: 2.2;
  }
}
//キービジュアル内の文字(absolute指定) 
.m-keyvisual {
    background-image: url(https://placehold.jp/2560x1136.png);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    @include mq(pc) {
        height: 58rem;
    }
    @include mq(sp) {
        height: 91rem;
    }

    //背景画像の上に背景色を重ねる
    &::after {
        content: '';
        // background-color: rgba(0,0,0,.5);
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        @include mq(pc) {
            height: 58rem;
        }
        @include mq(sp) {
            height: 91rem;
        }   
    }
    //キービジュアル内の文字(絶対位置指定)
    &_inner {
        position: relative;
        height: 100%;
        margin-right: auto;
        margin-left: auto;
        max-width: 1000px;
    }
    &_title {
        position: absolute;
        top: 50%;
        left: 0;
        padding: 40px;
        color: #fff;
        transform: translateY(-50%);
        margin-top: 0;
        margin-bottom: 0;
    
        @include mq(pc) {
            font-size: 3.2rem;
            line-height: 2.2;
        }
        @include mq(sp) {
            font-size: 4rem;
            left: 50%;
            width: 90%;
            padding: 15px;
            text-align: center;
            transform: translate(-50%, -50%);
        }
    }

    //キービジュアルのテキスト装飾
    &_emphasis {
        box-decoration-break: clone;
        -webkit-box-decoration-break: clone;
        display: inline;
        background-color: #e5c046;

        @include mq(pc) {
            padding: 1rem;
            font-size: 3.2rem;
            line-height: 2.2;
        }
        @include mq(sp) {
            padding: 1rem;
            font-size: 4.0rem;
            line-height: 2.2;
        } 
    }
}

//キービジュアル内の文字(flex指定) 
.m-keyvisual02 {
    display: flex;
    justify-content:center;
    align-items:center;

    &_inner {
        display: flex;
        height: 100%;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 0 auto;
        word-break:break-all;
        @include mq(pc) {
            width: $pcInn+px;
        }
        &Top {
            justify-content: flex-start;
        }
        &Bottom {
            justify-content: flex-end;
        }
        &Left {
            align-items: flex-start;
        }
        &Right {
            align-items: flex-end;
        }
    }

    &_title {
        display: flex;    
        @include mq(pc) {
            font-size: 3.2rem;
            line-height: 2.2;
        }
        @include mq(sp) {
            font-size: 4rem;
            line-height: 2.2;
        }
    }    
}
TOP