質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
CSS3

CSS(Cascading Style Sheet)の第3版です。CSS3と略されることが多いです。色やデザインを柔軟に変更することが可能になります。

HTML5

HTML5 (Hyper Text Markup Language、バージョン 5)は、マークアップ言語であるHTMLの第5版です。

Q&A

解決済

1回答

1712閲覧

ホームページの画像が切れてしまう・・・

aisya

総合スコア6

CSS3

CSS(Cascading Style Sheet)の第3版です。CSS3と略されることが多いです。色やデザインを柔軟に変更することが可能になります。

HTML5

HTML5 (Hyper Text Markup Language、バージョン 5)は、マークアップ言語であるHTMLの第5版です。

0グッド

0クリップ

投稿2021/01/11 15:19

前提・実現したいこと

ホームページをレスポンシブ対応させたいです。

発生している問題・エラーメッセージ

画像が切れてしまい、1000px以下にになった場合に画像が切れてしまいます。。。

該当のソースコード

HTML&CSS

1ソースコード 2@charset "UTF-8"; 3/*------------------------------ 4共通パーツ 5------------------------------*/ 6.section { 7 padding: 100px 0; 8 9.section__title { 10 margin-bottom: 50px; 11 font-size: 3.2rem; 12 line-height: 1.0; 13 text-align: center; 14} 15 16.section__title span { 17 display: inline-block; 18 padding: 10px 22px; 19 position: relative; 20} 21 22.section__title span::before, .section__title span::after { 23 content: ''; 24 display: block; 25 width: 16px; 26 height: 16px; 27 position: absolute; 28 z-index: 1; 29} 30 31.section__title span::before { 32 top: 0; 33 left: 0; 34 background: linear-gradient(135deg, #8b4513 0%, #8b4513 50%, transparent 50%, transparent 100%); 35} 36 37.section__title span::after { 38 right: 0; 39 bottom: 0; 40 background: linear-gradient(135deg, transparent 0%, transparent 50%, #8b4513 50%, #8b4513 100%); 41} 42 43.common-inner { 44 width: 1000px; 45 margin: 0 auto; 46} 47 48/* よく出てくる(であろう)ボタン */ 49.primary-button { 50 display: flex; 51 justify-content: center; 52 align-items: center; 53 min-width: 280px; 54 height: 60px; 55 padding: 0 20px; 56 box-sizing: border-box; 57 font-size: 1.6rem; 58 color: #ddd; 59 background-color: #fff; 60 border: 1px solid #ddd; 61 border-radius: 4px; 62 position: relative; 63 transition: 0.2s ease 0s; 64 transition-property: background-color, color; 65} 66 67.primary-button::before, .primary-button::after { 68 content: ''; 69 display: block; 70 width: 10px; 71 height: 10px; 72 position: absolute; 73 right: 5px; 74 bottom: 5px; 75 z-index: 1; 76 transition: opacity 0.2s ease 0s; 77} 78 79.primary-button::before { 80 background: linear-gradient(135deg, transparent 0%, transparent 50%, #8b4513 50%, #8b4513 100%); 81 opacity: 1; 82} 83 84.primary-button::after { 85 background: linear-gradient(135deg, transparent 0%, transparent 50%, #fff 50%, #fff 100%); 86 opacity: 0; 87} 88 89.primary-button:hover { 90 background-color: #008DD5; 91 color: #fff; 92} 93 94.primary-button:hover::before { 95 opacity: 0; 96} 97 98.primary-button:hover::after { 99 opacity: 1; 100} 101 102.primary-button--monochrome { 103 color: #333; 104 border-color: #333; 105} 106 107.primary-button--monochrome:hover { 108 background-color: #333; 109} 110 111.primary-button--monochrome::before { 112 background: linear-gradient(135deg, transparent 0%, transparent 50%, #333 50%, #333 100%); 113} 114 115/*------------------------------ 116ページヘッダー 117------------------------------*/ 118.page-header__inner { 119 display: flex; 120 align-items: baseline; 121 min-height: 480px; 122 height: 20vw; 123 padding: 10px; 124 background-image:url(../img/main-header.png); 125 background-size: cover; 126 position: relative; 127} 128 129.page-header__title { 130 font-size: 3.0rem; 131 line-height: 1.5; 132 color: #fff; 133 /* 背景色(黒) */ 134} 135 136.page-header__title .black-belt { 137 padding: 3px 5px; 138 background-color: #ddd; 139} 140 141.page-header__campaign { 142 position: absolute; 143 right: 20px; 144 bottom: 20px; 145 z-index: 1; 146} 147 148.page-header__campaign a { 149 display: flex; 150 justify-content: center; 151 align-items: center; 152 width: 180px; 153 height: 180px; 154 background-color: #fff; 155 box-sizing: border-box; 156 border: 5px solid #008DD5; 157 border-radius: 50%; 158 font-size: 2.4rem; 159 line-height: 1.5; 160 text-align: center; 161 color: #008DD5; 162 transition: 0.2s ease 0s; 163 transition-property: color, background-color; 164} 165 166.page-header__campaign a:hover { 167 background-color: #008DD5; 168 color: #fff; 169} 170 171/* css-browser-selectorを使って付与したクラス名を使って、影響範囲をwindowsに限定する */ 172.windows .page-header__title .black-belt { 173 padding: 2px 8px 0; 174 background-color:#ddd ; 175} 176 177/* ヘッダーのナビゲーション */ 178.header-navigation { 179 display: flex; 180 justify-content: space-between; 181 align-items: center; 182 padding-left: 100px; 183 background-color: #A9D92F; 184 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); 185} 186 187.header-navigation__list { 188 display: flex; 189} 190 191.header-navigation__list li { 192 line-height: 1.0; 193} 194 195.header-navigation__list li:first-child { 196 margin-left: -10px; 197} 198 199.header-navigation__list li:not(:last-child) { 200 margin-right: 30px; 201} 202 203.header-navigation__list li a { 204 display: inline-block; 205 padding: 10px; 206 font-size: 1.6rem; 207 line-height: 1; 208 color: #fff; 209 transition: opacity 0.2s ease 0s; 210} 211 212.header-navigation__list li a:hover { 213 opacity: 0.7; 214} 215 216.header-navigation__contact a { 217 display: inline-block; 218 padding: 30px 50px; 219 background-color: #A9D92F; 220 font-size: 1.6rem; 221 line-height: 1; 222 color: #fff; 223 position: relative; 224} 225 226.header-navigation__contact a::after { 227 content: ''; 228 display: block; 229 width: 100%; 230 height: 100%; 231 background-color: #fff; 232 opacity: 0; 233 position: absolute; 234 top: 0; 235 left: 0; 236 z-index: 1; 237 transition: opacity 0.2s ease 0s; 238} 239 240.header-navigation__contact a:hover:after { 241 opacity: 0.3; 242} 243 244/*------------------------------ 245最新情報 246------------------------------*/ 247.news-list { 248 width: 640px; 249 } 250time{ 251 text-align: center; 252} 253 254.news-list:not(:last-child) { 255 margin: 0 auto 30px; 256} 257 258.news-list__item a { 259 display: flex; 260 justify-content: space-between; 261 font-size: 1.6rem; 262 line-height: 1.75; 263 color: #000; 264 text-align: center; 265} 266 267.news-list__item a:hover { 268 text-decoration: underline; 269} 270 271.news-list__item a span { 272 width: 470px; 273} 274 275.news-list__item:not(:last-child) { 276 margin-bottom: 20px; 277} 278 279.news-page-link { 280 text-align: center; 281} 282 283.news-page-link a { 284 font-size: 1.6rem; 285 color: #008DD5; 286} 287 288.news-page-link a:hover { 289 text-decoration: underline; 290} 291 292/*------------------------------ 293サービスの特長 294------------------------------*/ 295#feature { 296 background-image: url(../img/header.png); 297 background-size: cover; 298 background-color: rgba(255,255,255,0.8); 299 background-blend-mode: lighten; 300} 301 302.feature-block{ 303 margin: 10px, 50px 50px 10px; 304} 305 306.feature-block__text { 307 width: 1000px; 308 font-size: 1.6rem; 309 line-height: 1.75; 310 text-align: center; 311} 312 313.feature-block__button { 314 margin-top: 40px; 315} 316 317/*------------------------------ 3183つの強み 319------------------------------*/ 320.advantage-list { 321 counter-reset: advantage-counter; 322 /* 「n番目」という概念自体がリストに依存するので、あえて「.advantage-listの子要素の.advantage-block__title:before」という形で記述する */ 323} 324 325.advantage-list__item:not(:last-child) { 326 margin-bottom: 50px; 327} 328 329.advantage-list .advantage-block__title:before { 330 counter-increment: advantage-counter; 331 content: counter(advantage-counter) ". "; 332} 333 334.advantage-block { 335 display: flex; 336 align-items: center; 337} 338 339.advantage-block__image { 340 overflow: hidden; 341 width: 300px; 342 height: 300px; 343 margin-right: 40px; 344 border-radius: 50%; 345} 346 347.advantage-block__inner { 348 flex: 1; 349} 350 351.advantage-block__title { 352 margin-bottom: 20px; 353 font-size: 2.4rem; 354 line-height: 1.5; 355 border-bottom: 2px solid #72d500; 356} 357 358.advantage-block__text { 359 font-size: 1.6rem; 360 line-height: 2; 361} 362 363/*------------------------------ 364カルーセル 365------------------------------*/ 366.carousel-block{ 367 max-width: 100%; 368 margin: 0 auto; 369} 370 371/*------------------------------ 372フォーム 373------------------------------*/ 374.contact-form { 375 width: 600px; 376 margin: 0 auto; 377} 378 379.contact-form__send-button { 380 margin: 50px auto 0; 381} 382 383.form-parts { 384 display: block; 385 margin-bottom: 30px; 386} 387 388.form-parts__label { 389 display: block; 390 margin-bottom: 10px; 391 font-size: 1.6rem; 392 line-height: 1; 393} 394 395input[type=text], input[type=email] { 396 display: block; 397 width: 100%; 398 padding: 10px; 399 box-sizing: border-box; 400 border: 1px solid #000; 401 border-radius: 4px; 402 font-size: 1.6rem; 403} 404 405.select-wrapper { 406 display: block; 407 width: 200px; 408 height: 40px; 409 border: 1px solid #000; 410 border-radius: 4px; 411 box-sizing: border-box; 412 position: relative; 413} 414 415.select-wrapper select { 416 width: 100%; 417 height: 100%; 418 padding-left: 10px; 419 box-sizing: border-box; 420 font-size: 1.6rem; 421} 422 423.select-wrapper::after { 424 content: ''; 425 display: block; 426 width: 12px; 427 height: 9px; 428 position: absolute; 429 top: 50%; 430 right: 10px; 431 z-index: 1; 432 transform: translateY(-50%); 433} 434 435textarea { 436 width: 600px; 437 height: 200px; 438 padding: 10px; 439 box-sizing: border-box; 440 border: 1px solid #000; 441 border-radius: 4px; 442 font-size: 1.6em; 443 line-height: 1.75; 444 resize: none; 445} 446 447/*------------------------------ 448ページフッター 449------------------------------*/ 450.page-footer { 451 padding: 50px 0; 452 background-color: #A9D92F; 453} 454 455.page-footer__nav { 456 display: flex; 457} 458 459.page-footer__nav .footer-nav-block:not(:last-child) { 460 margin-right: 100px; 461} 462 463.footer-nav-block__category { 464 margin-bottom: 40px; 465 font-size: 1.4rem; 466 line-height: 1.0; 467 color: #fff; 468} 469 470.footer-nav-block__list { 471 font-size: 1.4rem; 472 line-height: 1; 473} 474 475.footer-nav-block__list li:not(:last-child) { 476 margin-bottom: 20px; 477} 478 479.footer-nav-block__list li a { 480 color: #fff; 481} 482 483.footer-nav-block__list li a:hover { 484 text-decoration: underline; 485} 486/* メディアクエリ */ 487@media screen and (min-width:1000px) { 488 body{ 489 min-width: 1000px; 490 } 491 492 } 493} 494 495### 試したこと 496 497ボディ要素に対してmin-width:1000pxを試みましたが、直らず苦戦しています。 498 499 500### 補足情報 それ以外にもblock要素の変更などを試してみましたが、うまくいきません・・・

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

勘で回答してみます。


[1] まず以下をコメントアウトしてください。
(「bodyの横幅が最小1000px」という指定なので、例えば画面幅が900pxになってもbodyの幅が1000pxとなり、はみ出す原因になりそうです。)

@media screen and (min-width:1000px) { body { min-width: 1000px; } }

[2] width: 1000px;の指定がある箇所すべてに、max-width: 1000px;を指定してください。

.common-inner { /* width: 1000px; */ max-width: 1000px; margin: 0 auto; } .feature-block__text { /* width: 1000px; */ max-width: 1000px; font-size: 1.6rem; line-height: 1.75; text-align: center; }

画像、というのはbackground-image:url(../img/main-header.png);など背景画像のことだと理解しています。

うまくいけば解決できるかもしれません。


背景画像 (background-image) ではなく、画像 (<img>) の場合、以下の[3]を指定してみてください。

[3] とりあえず画像の横幅の最大値を指定

img { max-width: 100%; }

投稿2021/01/11 22:54

new1ro

総合スコア4528

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

aisya

2021/06/14 11:20

ありがとうございます。解決できました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問