2017-11-22 29 views
0

ホームページのバナー画像にメディアクエリを追加しようとしています。私はそれが反応し、使用される画面に応じて3つの異なる画像サイズに更新したい。現在、中程度のサイズの画像のみが表示されます。私のコードに何が間違っているのかを教えてください。ありがとう。これらのメディアクエリはどのように動作させるのですか?

/*--------------------------------------------- 
     Section#Slider [Banner Image] 
-----------------------------------------------*/ 
/* NEXUS 5 Size 412px, XS 
(less than 786px no media query since this is 
default in Bootstrap) 
*/ 

/* IPAD SIZE 768px and up, S*/ 

@media screen and (min-width: 550px) { 
    #slider { 
     background: url("../img/smartphoneweb_640x285.jpeg") no- 
     repeat; 
     background-size: cover; 
     background-attachment: fixed; 
     background-position: 10% 0%; 
     padding: 200px 0 280px 0; 
     position: relative; 
    } 
} 

/* MD, desktops, 992px and up */ 

@media (min-width: 950px) { 
    #slider { 
     background: url("../img/smartphoneweb_1280x570.jpeg") no- 
     repeat; 
     background-size: cover; 
     background-attachment: fixed; 
     background-position: 10% 0%; 
     padding: 200px 0 280px 0; 
     position: relative; 
    } 
} 

/* LG, large desktops, 1200px and up */ 

@media (min-width: 1200px) { 
    #slider { 
     background: url("../img/smartphoneweb_1920x855.jpeg") no- 
     repeat; 
     background-size: cover; 
     background-attachment: fixed; 
     background-position: 10% 0%; 
     padding: 200px 0 280px 0; 
     position: relative; 
    } 

} 
+0

すぎのような最大幅を設定してみてください "(最小幅:950px)@mediaと(最大幅:1199px){" –

+1

使用 '代わりに分'のMAX-width' -width' – Eranda

+0

なぜですか?私は間違っていない場合でも彼は最小幅が必要です@エランド –

答えて

0

あなたが主な問題は、あなた992pxメディアクエリで画面を追加するのを忘れたmin and max media query

@media screen and (min-width: 550px) and (max-width: 950px){ 
     #slider { 
      background: url("../img/smartphoneweb_640x285.jpeg") no- 
      repeat; 
      background-size: cover; 
      background-attachment: fixed; 
      background-position: 10% 0%; 
      padding: 200px 0 280px 0; 
      position: relative; 
     } 
    } 

    /* MD, desktops, 992px and up */ 

    @media (min-width: 950px) and (max-width: 1200px){ 
     #slider { 
      background: url("../img/smartphoneweb_1280x570.jpeg") no- 
      repeat; 
      background-size: cover; 
      background-attachment: fixed; 
      background-position: 10% 0%; 
      padding: 200px 0 280px 0; 
      position: relative; 
     } 
    } 
    @media (min-width: 1200px){ 
     #slider { 
      background: url("../img/smartphoneweb_1920x855.jpeg") no- 
      repeat; 
      background-size: cover; 
      background-attachment: fixed; 
      background-position: 10% 0%; 
      padding: 200px 0 280px 0; 
      position: relative; 
     } 

    } 
2

使用spicifique画面サイズのスタイルを扱うことができます。

は、ここに私のコードです。私はこれを参考に変更を加えました。

/*--------------------------------------------- 
 
     Section#Slider [Banner Image] 
 
-----------------------------------------------*/ 
 
/* NEXUS 5 Size 412px, XS 
 
(less than 786px no media query since this is 
 
default in Bootstrap) 
 
*/ 
 

 
/* IPAD SIZE 768px and up, S*/ 
 

 
@media screen and (min-width:0px) and (max-width:550px) { 
 
    #slider { 
 
     background: url("../img/smartphoneweb_640x285.jpeg") no- 
 
     repeat; 
 
     background-size: cover; 
 
     background-attachment: fixed; 
 
     background-position: 10% 0%; 
 
     padding: 200px 0 280px 0; 
 
     position: relative; 
 
    } 
 
} 
 

 
/* MD, desktops, 992px and up */ 
 

 
@media screen and (min-width:551px) and (max-width:992px){ 
 
    #slider { 
 
     background: url("../img/smartphoneweb_1280x570.jpeg") no- 
 
     repeat; 
 
     background-size: cover; 
 
     background-attachment: fixed; 
 
     background-position: 10% 0%; 
 
     padding: 200px 0 280px 0; 
 
     position: relative; 
 
    } 
 
} 
 

 
/* LG, large desktops, 1200px and up */

関連する問題