简体   繁体   中英

Css background image cover, fight height and width

I have this html code to create a background to my div :

<div id="secondBigDiv">test</div>

This is my css code :

#secondBigDiv{
    background: url(../images/myposts/background.jpg)no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

This code works perfectly as I want but the problem is:

  • I couldn't fit the height also, when i scroll down I find empty white spaces because my background image didn't fit the height, it fits the width.

Any help?

I would try putting each image property in its own line. background-repeat,background-attachment, etc

May not change anything but seems to work for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM