Best way to background cover cross browser - css

I have a 1024*768px image that I want to use as a background for a webpage.
I also want this background to cover the background of the entire window, even when it's resized. And.... I wan't the image to stretch least as possible!
I've tried the examples here, except the jquery one - since I'd like it better if only done in css.
thank you!
edit: here's the link: http://css-tricks.com/perfect-full-page-background-image/

You could try the backstretch plugin
It is a one line javascript solution, just include it (also jquery) in your headers and call it as the example:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="jquery.backstretch.min.js"></script>
<script>
// To attach Backstrech as the body's background
$.backstretch("path/to/image.jpg");
</script>
Official page:
http://srobbin.com/jquery-plugins/backstretch/
Github source:
https://github.com/srobbin/jquery-backstretch

I think some good old CSS can come in handy on things like this. This works well on desktop browsers and my iPhone/iPad:
html {
background: url(YOUR-IMAGE-URL) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 100%;
overflow: hidden;
}
body {
background: url(YOUR-IMAGE-URL) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 100%;
overflow: auto;
}

Related

Wordpress Image is not resize on browser and devices

I'm looking for so long to fix my issue with an full image background in wordpress and the image is awesome but is will not resize on browser and devices. Is there any css trick to do the job?
Here is my website http://www.social-boost.nl also the sign up form is important...... I hope somebody can help me out with this.
What about cover (CSS):
html {
background: url(wp-content/uploads/2018/02/landingsbnew20182.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Updated answer to overwrite interfering CSS rules:
html {
background: url(wp-content/uploads/2018/02/landingsbnew20182.jpg) no-repeat center center fixed !important;
-webkit-background-size: cover !important;
-moz-background-size: cover !important;
-o-background-size: cover !important;
background-size: cover !important;
}

CSS Background 100% Issue

I am new still a beginner to CSS and I have been having problems with getting my background to fill the age. I know contain and cover won't help me but even things like background-size and the widthand height commands aren't helping.
body {
background-image:url(X.png);
background-repeat:no-repeat;
width:100%;
height:100%;
}
Use html instead of body. cover should work, but it may depend on the browser as to how it act's for instance you may need to use -moz-background-size:cover if the browser is mozilla based.
Try add these style below:
min-width: 100%;
min-height: 100%;
width: 100%;
height: 100%;
background-size: cover;
-ms-background-size: cover;
-o-background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
It should work, please check my jsfiddle link:
http://jsfiddle.net/chris_poetfarmer/9xa35pwp/

background-size: cover not responsive

So I have a full screen background set up like so:
#div {
background-image: url("images/slide1.jpg");
background-position: center 20%;
background-attachment: fixed;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
width: 100%;
}
The background image resizes according to all view ports sizes, but when I view the site from my mobile, it seems to be displaying a very small section of the whole image - basically the background-size: cover; rule doesn't seem to working. It should also be noted that if I make the window on my computer phone size, the background resizes properly. It also resizes properly when I view it using the responsive display tool 'responsivetest.net'. Just not when I actually open it on a phone.
Any suggestions are, as always, much appreciated.
I'm doing something similar for a portfolio site that's in development and it works fine on mobile. Here's my working code for CSS:
display: table;
width: 100%;
height: auto;
padding: 100px 0;
background: url(../img/bbg1.jpg) no-repeat bottom center scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
So you can see some things you can try changing, such as the display height.
Test this site on your mobile device

Fullscreen background img combined with Fullscreen repeating background

I'm trying to place a fullscreen background image combined with a repeating background image without the use of J-query. Is it possible?
This is the code I use to get my image fullscreen:
body {
background: url(../img/bg1.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
But now I want this completely overlapped by a .png image background that needs to have a repeat function, for the simple reason that the .png contains lines which will rescale and look awful on certain screen sizes.
Any ideas?
Already tried:
Giving html a background and body a background, it will only display one of both.
Be aware that multiple backgrounds won't work on ie8 if needed:
http://caniuse.com/multibackgrounds
This answer will work on every browser:
You must give width and height to the elements.
You can see answer here: http://jsfiddle.net/Rc38f/
HTML Code:
<html>
<body>
<div id="wrapper"></div>
</body>
</html>
CSS Code:
html {
width: 100%;
height: 100%;
}
body {
background-image: url('http://www.colourbox.com/preview/4632391-637684-seamless-small-white-flowers-pattern-background.jpg');
background-repeat: repeat;
width: 100%;
height: 100%;
}
#wrapper {
background: url('http://i.telegraph.co.uk/multimedia/archive/02403/Jonstockshooting_2403237b.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
width: 100%;
height: 100%;
}
It is possible to include two background images on one tag.
How it Works
Multiple background images can be specified using either the
individual background properties or the background shorthand property.
This should be a Helpful resource to get you started.
css:
body {
background-image: url(http://www.wallcoo.com/paint/Chiplegal_vector_art/images/%5Bwallcoo.com%5D_vector_art_0seasons.jpg), url(http://nopgc.org/v2/images/body_bg.jpg);
background-position: top center, center;
background-repeat: no-repeat, repeat;
width: 100%;
height: 100%;
}
fiddle: Demo

CSS fixed background has white line on the left

I tried to put a background on my whole page with
html {
background: url(images/panda.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
This generally works just fine, but I have discovered a problem: On the left-hand side of the screen is a white stripe. Is it possible to fix that?
PS: Just in advance: No, that stripe is not on the picture. You can get an impression of how it looks:
EDIT: http://jsfiddle.net/uhwcW/
When zooming in/out the white stripe sometimes disappears or switches sides... Confusing.
Try;
margin: 0;
padding: 0
in your CSS for html.
Have you tried to reset your body? Try this for other containers too, maybe it's just some margin or padding you're seeing...
body {
margin: 0;
padding:0;
}
this worked for me..
html{
background: url(..//index3.jpg) no-repeat 0 0 fixed;
-webkit-background-size: cover;
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
-moz-background-size: cover;
}
Just adding a center after the url did it for me
like this:
background: url(images/panda.jpg) center;

Resources