2017-02-05 115 views
0

當我將圖像添加到我的HTML正文標籤作爲背景時,我獲得了圖片的放大視圖作爲背景。我怎樣才能讓實際的圖像適合作爲背景圖像的窗口?我試過但不工作使背景圖像適合窗口

<body background="home_back.jpg" class="img-fluid" alt="Responsive image" > 

謝謝。

+0

可能重複[this](http://stackoverflow.com/questions/29463586/why-is-my-background-image-so-zoomed-in)這個問題。 –

回答

1

你爲你的CSS做了什麼?

以下是您可以使用的一種方法。

<body background="http://images.fineartamerica.com/images-medium-large-5/3-american-bald-eagle-in-flight-michel-soucy.jpg" class="img-fluid" alt="Responsive image"> 

.img-fluid { 
    width: 100%; 
    background-repeat:no-repeat; 
    background-size:100% 500px; 
} 

的CSS將會使圖像佔據整個屏幕,並使其只顯示一次。 CSS Trick's full page bg images可能是一個很好的閱讀爲此:)