2016-11-21 9 views
-2

私は状況があります。ヘッダー全幅イメージを使用しているので、幅は100%、高さは650pxに固定されています。 ブラウザの幅を増減する場合、背景画像は幅を増減するだけで、画像を垂直方向に移動させることはありません。背景画像の縦の高さ

私はそれを理解できないと思います。そうでない場合はenought、ここではスクリーンショットが

現状である

enter image description here

私の希望状況

enter image description here

SCSSコード

header { 
    margin-top: 78px; 
    background-repeat: no-repeat; 
    background-position: center; 
    background-size: cover; 
    position: relative; 
    max-width: calc(100% - 120px); 
} 

.header-main { 
    background-image:url(../img/header.jpg); 
    height: 650px; 
    margin-left: 60px; 
    margin-right: 60px; 
} 

HTML

<header class="header-main" > 
     ---Content--- 
</header> 

は秀ありがとうございました:)

答えて

1

は、バックグラウンド・サイズ

header { 
    margin-top: 78px; 
    background-repeat: no-repeat; 
    background-position: center; 
    background-size: auto 650px; 
    position: relative; 
    max-width: calc(100% - 120px); 
} 

.header-main { 
    background-image:url(../img/header.jpg); 
    height: 650px; 
    margin-left: 60px; 
    margin-right: 60px; 
} 
+0

を変更しようと先端いただきありがとうございますが、それは全幅 – JZK

+0

に画像を伸ばしていないよう生憎それは働いていませんbackground-sizeのピクセルで 'auto'を全幅に変更します:auto 650px? –

+0

実際には、それはありがとうございます:) – JZK