LoginSignup
0
1

More than 3 years have passed since last update.

【CSS】画像と台形のテキストボックスを重ねたアイキャッチの作り方

Last updated at Posted at 2020-01-18

【CSS】画像と台形のテキストボックスを重ねたアイキャッチの作り方

オンライン学習サイトの画像を想定しています。

※レスポンシブだと表示が崩れるため注意

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="relative mv">
    <!--左側画像部分-->
    <img src="./img/school.jpg" alt="">
    <!--/左側画像部分-->
    <!--右側テキストボックス-->
    <div class="my-parts absolute">
      <div class="textWrapper">
        <h2>
          洗練されたオンライン学習体験を。
        </h2>
        <div class="box">
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda rem laboriosam quidem quasi deserunt delectus animi suscipit ratione modi illum ipsa ipsum dicta aliquid, consequatur exercitationem! Minima at facere deserunt!
        </div>
        <div class="box">
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Odio, accusantium aspernatur atque quidem pariatur placeat iure alias consectetur, fuga, debitis ipsum? Eum sit cumque dolores tempora laborum consequuntur neque voluptas.
        </div>
        <div class="btnWrapper">
          <p class="btn orange">
            <a href="">お問い合わせ</a>
          </p>
          <p class="btn aqua">
            <a href="">詳しく見る</a>
          </p>
        </div>
      </div>


    </div>
    <!--/右側テキストボックス-->
</body>
</html>
style.css
* {
  padding: 0;
  margin: 0;
}

a {
  cursor: pointer;
  color: black;
  text-decoration: none;
}

/*.mv*/
.relative {
  position: relative;
  width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}
.absolute {
  position: absolute;
}

/*.mv img*/
.relative img {
  width: 500px;
  height: 100%;
}

/*右側*/
.my-parts {
  border-bottom: 334px solid cornflowerblue;
  width: 600px;
  height: 0px;
  border-left: 50px solid transparent;
  right: 0;
}

.textWrapper {
  padding: 30px;
}

h2 {
  text-align: center;
}


/*ボタン部分*/
.btnWrapper {
  display: flex;
  justify-content: space-around;
  margin-top: 10px;
}

p.btn {
  width: 40%;
  text-align: center;
  border: 2px solid grey;
  border-radius: 30px;
}

p.btn a {
  display: block;
  padding: 10px 0;
}

.aqua {
  background-color: aqua;
}

.orange {
  background-color: orange;
}

p.btn:hover {
  opacity: 0.8;
  transition: all 0.5s;
}
/*/ボタン部分*/
0
1
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
1