I have the problem that my background suddenly cuts off. It worked normally before on chrome, but now I cuts off in the middle of the page (http://prntscr.com/kwsaxn).
My CSS Code:
html, body {
background: url(../images/background.jpg) no-repeat center fixed;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
Executed in the header:
<link rel="stylesheet" href="css/style.css">
I don't seem to find any options online how to solve that, but maybe it's as simple as in my last questions and I'm just missing something.
Maybe it has something to do that the is called right where it ends, but I had it like that before when it still worked.
PS: I tested it on edge, chrome and my iphone safari.
Thanks :)
please give the link of website or codepen editor
I'm using Bootstrap 3 for my interface page on a site i manage. I set my full page background image using this CSS:
background-image:url('/path/to/image.jpg');
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
background-size: cover;
It works great... On desktop. On mobile, the image gets resized to to a very small resolution and it gets pushed up, above a bootstrap 3 panel.
Here is a picture. On desktop, the picture covers the full page.
And here is a jsfiddle.
The thing is that it works great if i remove the bootstrap code; for example on another page not using bootstrap, the same CSS is used. The image scales nicely on desktop and on mobile.
What could be the problem?
Thanks
I am not sure, but maybe depending on the browser you are using on the mobile phone?
Try adding:
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
I might be wrong, but worth a shot.
Hope it helps.
Finally i used; <img src="/resources/ui_bg.jpg" style="width:100%;height:100%;position:absolute;top:0;left:0;z-index:-5000;" alt="">
Thanks guys!
I am trying to use a free web template. But I cannot figure out how can I fix the background image. Does anyone give an idea to solve this problem. I wanted to show the code but don't know which part to give.. I can show this on desktop with no problem.
set the height & width = 100% also div's too
Try having a look at the css3 background property
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I am sure it solves your purpose.
Have a look this link for detailed info
http://css-tricks.com/perfect-full-page-background-image/
Also as Syed mentioned, study about responsive design or stick to some framework like Bootstrap.
I created a background for my website using CSS code it successfully worked but the problem is once I run it on different screen whether it was big or small I don't get similar consequences. When I run it on 13 inch screen the browser zooms in and the form what I get is probably not the same as in 18 inch well it obviously wouldn't have the exactly form but more or less I need it to be shown look-like. any suggestions? thnx in advance
body {
background-image: url(../images/background.jpg);
background-repeat: no-repeat;
}
An addition problem I have now is that the background isn't full-screen. its resolution is 1920x1080, though I can see the picture on the whole web browser page but still I couldn't see other details of the photo.
I think you need
background-size: cover;
There are some browser inconsistencies, which might mean it is better to use a jquery plugin.
Have a look at http://srobbin.com/jquery-plugins/backstretch/ it allows you to use a background image which resizes depending on the size of the screen. It also deals with IE. Nuff said.
Also look at http://css-tricks.com/perfect-full-page-background-image/
I'm not 100% on what you are trying to achieve but the above links are worth a look.
This is the css3 way
html {
background: url(../images/background.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Is anyone else having this issue? I create websites for a living, and some employ the use of the css property background-size: cover. All of the sudden about 1 week ago, all of the sites with this property no longer display right in Google Chrome. (all other browsers are working fine.) Is anyone else experiencing this? Is it just MY google chrome or did something change? Because the backgrounds were displaying properly until about a week ago, and I did not change anything. They just stopped displaying properly, seemingly out of nowhere....
Best practice: always set background-image first and then background-size.
You only need to use !important :
background-size: cover !important;
I just ran into this problem in Chrome, too.
None of the above answers worked for me. Specifically, I was trying to set the <body> element background to background-size: cover. However, the background image would never extend vertically to fill the page.
After some trial and error, I found that setting the <html> element width and height to 100% fixed the problem in Chrome. (For what it's worth, changing the <body> element's width and height seemed to have no effect.)
In my css, I have the following rules to fix the issue:
html {
width: 100%;
height: 100%;
}
I was having the same problem all of a sudden w/ not only GC but also FF and Opera. i was using a php function to pull random images for my background and this is what i had....
CSS:
.main-slideshow .video img {
cursor:pointer;
width:550px !important;
height:340px !important;
background-repeat: no-repeat;
-moz-background-size:cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover; }
and HTML/PHP:
$result .='<img alt="" style="background:url('.$thumbnail.')" src="/images/play1.png" /> ';
it was working for some days and suddenly background-repeat and background-size stopped working. so this morning i found out that the following changes are working perfectly for GC (v21), FF (v14), Opera (v12) and Safari (v5.1.7)...still no luck w/ IE though :(
CSS:
.main-slideshow .video img {
cursor:pointer;
width:550px !important;
height:340px !important;
-moz-background-size:cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover; }
HTML/PHP:
$result .='<img alt="" style="background-image:url('.$thumbnail.')" style="background-repeat: no-repeat" style="background-size:cover" src="/images/play1.png" />';
may be it's a lousy solution but it's working for me (so far) hope this helps some one :)
The following is a solution to the problem, but it won't be for everybody. I estimate that this solution will help a minority of the people experiencing the author's problem.
The background-size option can stop working in chrome if your container is too small, vertically, compared to your background image.
I was in a situation where I had to position a small portion of a large background image across a div that was 7 pixels tall.
In the Chrome debugger, changing the div height to 9 pixels "snapped" the background-size into place.
My ultimate solution was to restructure my divs so that I would not run into this problem.
To see if this solution will help you, in the Chrome debugger, enlarge your div. If, at some point, the background-size snaps into place, then you know this is the issue.
Old question but has similiar issue and it turned out I needed to add and to the empty div's I was applying background-size: cover to.
You must do CSS hacks for google chrome.
Use body:nth-of-type(1) .elementOrClassName{property:value;}
only for google chrome.
for your case,
nth-of-type(1) .elementOrClassName{background-size:80px 60px;}
Try this
background-size:contain;
For me, following worked for Chrome, IE 8, IE 9:
.itemFullBg{
background:url('image/path/name.png') no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-size:100% 100%;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader
(src='image/path/name.png',sizingMethod='scale');
}
You can fix the problem by setting the height of the tag.
For example, if you have a page that has a background image, set the height of the html and body tags in the CSS, like so:
html { height:100%; min-height:100%; } body{ min-height:100%; }
hope this helps
Instead of using:
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
Use:
-webkit-background-size: 100% 100%;
-moz-background-size: 100% 100%;
-o-background-size: 100% 100%;
background-size: 100% 100%;