-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Hey.
While trying to find a solution for this seriously stupid problem, I came across your blog post about background-size: cover.
The past five days, I have spent implementing a tiny little background animation - which works and looks nice. But then when I tested it on my Phone, I realized how broken the background was.
So I added that very property with value cover only to see that the background continued to scroll... So I am a lot lost. Without the property, all my background does is stay in the center of the page - adjusted by it's width instead of being in the way i want.
background-size: cover however breaks the zoom-in effect (as in, the image is always centered in the background and looks good). When applied, the image is scaled by its width, and i have black bars on the top and bottom since the background is not fully streched... So its either this or that. See why my mind is "roasted"? :)
My HTML markup looks a bit like this:
<!DOCTYPE html>
<html>
<head> ... </head>
<body>
<div id="bg"></div> <!-- the real background -->
<div class="blurr-bg"></div> <!-- The background with a blur filter -->
<div id="MainPage"> ... </div> <!-- This holds everything from the top to the actual content -->
<footer id="footer"></footer> <!-- I use the jquery.stickyfooter plugin, that is why it is separated from #MainPage -->
</body>
</html>And the CSS for #bg and #blurr-bg:
body {
background-color: black;
color: white;
height: 100%;
width: 100%;
z-index: 0;
position: relative;
}
#blurr-bg, #bg {
background: url("/cdn/theme/images/bg.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
#bg {
z-index: -2;
}
#blurr-bg {
z-index: -1;
-webkit-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
-Ms-filter: blur(5px);
-khtml-filter: blur(5px);
filter: blur(5px);
}I also use a bit of PHP to determine mobile safari. If it is found, this is also present:
@media only screen and (max-width: 767px) {
#blurr-bg, #bg {
background-size: cover;
}
}So... Do you see anything that could cause all these issues with the background? The blurred background is what is mostly visible. There is a transistion from the non-blurred background to the blurred one on the index page that is handled via JavaScript and jQuery.fracs (the less of the intro section is visible, the more blurred is the bg).
Any help would be really appreciated!
Kind regards,
Ingwie