简体   繁体   中英

Backstretch and background-size: cover

I'm currently using CSS for full screen background one my single page website (composed of several DIVs of 1300px height under each other). It works well, the background image is full screen on the visible part of the page, but it doesn't work on ipad. The issue with backstretch is that if I include this code

 <script>
 $("#medias").backstretch("../images/bg-18.jpg");

within my "medias" DIV, the background image covers the full size of my DIV (so 1300 height * width) which is not what I want it to cover the browser window only Many thanks

Example of a DIV with CSS method:

#medias {
    height: 1300px;
    background: #8aba56;
    padding-top: 150px;
    background: url(../images/bg-18.jpg) no-repeat center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    background-size: cover;
    -ms-background-size: cover;
    -o-background-size: cover;
}

I ended up using backstretch initially because the css didn't seem to work on ipads. Exactly as you've described. However, oddly enough, after experimenting with the CSS, and changing this:

background-image: url('background.jpg');

to,

background-image: url ('www.imgur.com/background.jpg')

The background worked on the iPad. It seemed that changing the background-image location to a direct url the iPad was able to produce the image. So, try uploading your image to a temporary server (like imgur), and then changing the link in your CSS, to the imgur link.

Strangely enough it worked 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