我有一張非常酷的照片作爲我的網站組合,但我不能得到它的響應和適合div。它填滿了整個div,但整張照片沒有妥當。我正在使用bootstrap。如何讓背景照片適合div和Css響應?
這是我的CSS
.bg1 {
background-image: url (../img/brain.jpg);
background-size: 100%;
height: 600px;
}
我有一張非常酷的照片作爲我的網站組合,但我不能得到它的響應和適合div。它填滿了整個div,但整張照片沒有妥當。我正在使用bootstrap。如何讓背景照片適合div和Css響應?
這是我的CSS
.bg1 {
background-image: url (../img/brain.jpg);
background-size: 100%;
height: 600px;
}
試試這個:
.bg1{
background-image: url (../img/brain.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
演示link
此處瞭解詳情:Perfect Full Page background
你可以嘗試用<img>
標籤載入圖片,並添加img-responsive
c lass是Bootstrap支持的。查看更多內容http://www.w3schools.com/bootstrap/bootstrap_ref_css_images.asp