28
September
Grid2
完成イメージ
header、ロゴマーク追加
※画像はsvg/png/jpg/gifいずれも可
ロゴ例(サイズ:180px/180px)
Box構造
追加html
1 2 3 |
<header> <h1><img src="#" alt="#"></h1> </header> |
指定校:ロゴマークはヘッダー内上下左右共中心に配置、画像は背景画像
Grid基準
余白
html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<div class="container"> <header><h1><img src="img/logo.svg" alt="はっぴねスフィットネスクラブのロゴ画像"></h1></header> <section> <a href="#" class="caption"> <h2>About Us</h2> <p>充実の施設&プログラムをご用意!<br>ぜひ一度、体感してみてください。 今なら、お得にはじめられます。 </p> </a> </section> <section> <a href="#" class="caption"> <h2>Course Info</h2> <p>自転車タイプのエアロバイク、室内で安全に走ったり歩いたりできるランニングマシン等多種多様プログラムをご用意しています。</p> </a> </section> <section> <a href="#" class="caption"> <h2>Staff Blog</h2> <p>日々の活動や指導方針を、スタッフやコーチの生の声でお届けします。</p> </a> </section> <section> <a href="#" class="caption"> <h2>Trainners</h2> <p>当クラブのトレーナーは経験豊富で、会員様に応じて、最適な指導を行なっています。</p> </a> </section> <section> <a href="#" class="caption"> <h2>Club Info</h2> <p>当クラブのご案内です。体験コース、入会案内、ロケーション等をご紹介します。</p> </a> </section> </div> |
css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
@charset "utf-8"; /*----Reset----*/ *{ margin: 0; padding: 0; } body{ font-family: "Hiragino Kaku Gothic ProN", Meiryo,sans-serif; line-height: 1.0; } ul{ list-style: none; } a{ text-decoration: none; color: inherit; display: block; } img{ max-width: 100%; height: auto; vertical-align: bottom; } /*----Grid Container----*/ .container{ height: 100vh; box-sizing: border-box; background: rgb(32, 118, 164); color: #fff; display:grid; grid-template-columns: 200px 2fr 1fr 1fr 2fr; grid-template-rows: 1fr 1fr; gap: 20px; padding: 20px; } /* 角丸 */ header,section{ border-radius: 20px; } /* Grid item */ header{ background:rgb(2, 61, 82); grid-column:1; grid-row: 1/3; position: relative; } header h1{ width:180px; height: 180px; position: absolute; inset: 0; margin: auto; } header img{ border-radius: 50%; } .container section:nth-of-type(1){ background: url(../img/hero4.png) no-repeat center/cover; grid-column:2/4 ; grid-row: 1; } .container section:nth-of-type(2){ background: url(../img/hero1.png) no-repeat center/cover; grid-column: 4/6; grid-row:1 ; } .container section:nth-of-type(3){ background: url(../img/hero3.png) no-repeat center/cover; grid-column:2 ; grid-row:2 ; } .container section:nth-of-type(4){ background: url(../img/hero5.png) no-repeat center/cover; grid-column: 3/5; grid-row: 2; } .container section:nth-of-type(5){ background: url(../img/jim.png) no-repeat center/cover; grid-column:5 ; grid-row: 2; } /* キャプション */ .caption { color: #fff; background: rgba(0, 0, 0, 0.4); /*aをsectionに合わせる*/ box-sizing: border-box; height:100%; padding-top:25vh; opacity: 0; transition: 300ms; } .caption:hover { opacity: 1; } /* caption内テキスト */ .caption h2 { font-family: 'Tangerine', cursive; text-align: center; font-size:4em; margin-bottom: 20px; } .caption p { width: 80%; margin: 0 auto; line-height: 1.4; } @media screen and (max-width:1240px) { /*----Grid Container----*/ .container{ grid-template-columns: 2fr 1fr 1fr 2fr; grid-template-rows: 100px 1fr 1fr; } /* Grid Item */ header{ grid-column: 1/5; grid-row: 1; } header h1{ width:80px; height: 80px; } .container section:nth-of-type(1) { grid-column: 1/3; grid-row: 2; } .container section:nth-of-type(2) { grid-column: 3/5; grid-row: 2; } .container section:nth-of-type(3) { grid-column: 1; grid-row: 3; } .container section:nth-of-type(4) { grid-column: 2/4; grid-row: 3; } .container section:nth-of-type(5) { grid-column: 4; grid-row: 3; } /* Caption */ .caption{ opacity: 1; border: 1px solid #fff; padding: 20px; width:80%; margin: 0 auto; height: auto; margin-top: 20vh; } .caption h2 { font-size:2.8em; margin-bottom: 10px; } .caption p { width: auto; } } @media screen and (max-width:743px) { /*.container*/ .container { display: block; height: auto; padding: 10px; } /* Header高さ */ header{ height: 100px; } /* Grid Item */ .container section:nth-of-type(1), .container section:nth-of-type(2), .container section:nth-of-type(3), .container section:nth-of-type(4), .container section:nth-of-type(5){ margin-top:10px; height: calc((100vh - 140px)/2); box-sizing: border-box; padding-top: 10vh; } /* Caption内側余白 */ .caption{ margin-top: 0; padding: 10px; } /* h2サイズ調整 */ .caption h2 { font-size:3em; } } /* iPhone5/SE用 */ @media screen and (max-width:320px) { .caption h2 { font-size:2em; margin-bottom: 5px; } .caption p{ font-size: 13px; } } |
Responsive設定
html追加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<!-- Hamburger Btn --> <div class="btn"> <i class="fas fa-bars"></i> <i class="fa-solid fa-xmark"></i> </div> <!-- Sp nav --> <nav class="spnav"> <ul> <li><a href="#"><i class="fas fa-user-tie"></i>About Us</a></li> <li><a href="#"><i class="fas fa-info-circle"></i>Course Info</a></li> <li><a href="#"><i class="fas fa-file-alt"></i>Staff Blog</a></li> <li><a href="#"><i class="fas fa-users"></i>Trainners</a></li> <li><a href="#"><i class="fas fa-dumbbell"></i>Club Info</a></li> </ul> </nav> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> // $(function(){ $('.btn').on('click',function(){ $(this).toggleClass('close'); $('.spnav').slideToggle(); }); // }); </script> |
css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
/* Hambruger Btn */ .btn{ display: block; color: #fff; border: 1px solid #fff; border-radius: 5px; width:50px; line-height: 50px; height: 50px; text-align: center; overflow: hidden; font-size: 35px; position: absolute; top:25px; right: 25px; } .btn i{ display: block; line-height: 50px; } .close i:first-child{ display: none; } /* Sp Menu */ .spnav{ /* display: block; */ position: absolute; top: 77px; background:rgba(0, 50, 100, 0.6); width:100%; } .spnav li{ color: #fff; line-height: calc((80vh - 77px)/5); border-top: 1px solid #ccc; font-size: 26px; } .spnav li:last-child{ border-bottom: 1px solid #ccc; } .spnav a{ padding-left: calc(50% - 3em); } .spnav i{ margin-right: 5px; } |