Full-screen background image on container-fluid - css

I'm trying to get a background image to fill the screen on a container-fluid div and it is not working. I've done quite a bit of research, but here's the problem: the website I'm working on is on a platform on which I have absolutely no ability to edit the html. This is the website for my HOA (Homeowner's Association), and they use a god-awful platform - HOA Express. The only customization ability I have is a "Custom CSS" box on the website settings page. The website's url is.
I had a full-screen background image on the site previously, but this week they updated their whole system from something circa 2002 to I assume a version of bootstrap (with which I am not very well-versed), and in doing so they wiped out all existing custom css, so I have to go in and redo everything.
Any ideas on what I might try? Is this even possible?

You are missing background-size: cover from my example. However this will "zoom" the image, and I don't think that is what you want. I suppose you want the image to fill the viewport, and stay there. To achieve this you need to set your background to cover "100%" and be fixed.
So basically you add this.
.container-fluid {
background-size: 100% 100%;
background-attachment: fixed;
}

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;
width:100%;
Add background-size and width to the image

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;

Related

Is it possible to add/alter css to a website to display a background image from your harddrive?

I have a chrome extension that lets me add css to any website. I am trying to put a background using an image on my harddrive, but can't get it to work.
For this example I am using www.google.com
If it makes a difference, the chrome extension I am using is called Stylebot
This the CSS I added
body {
background:#F9F0C9 url("file:///C:/Users/username/OneDrive/Documents/PaperPAge/5-wrinkled-parchment-paper1final2.png") center center fixed;
background-repeat: repeat-x;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
The #F9F0C9 color is added to the background, so something is working, but selected background image does not appear.
Stylebot is a Chrome extension and thus all scripts, including the CSS parser, are written in JavaScript. #C.Dhruv is correct, there is no Chrome method for arbitrarily reading files from a user's local disk without prompting them. If possible, I would recommend uploading the image to either your own public-facing webserver or some image hosting site and reference the URL accordingly in your code snippet above.
Please change background to background-image
then your code will be
body {
background-color:#F9F0C9;
background-image:url("file:///C:/Users/username/OneDrive/Documents/PaperPAge/5-wrinkled-parchment-paper1final2.png") center center fixed;
background-repeat: repeat-x;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

Wordpress section background - responsive auto-scaling?

I'm building a wordpress site and I have a section background set. I used an image with 1920px width. On my 1366px screen the image is not scaling, but is cut-off from the right by the pixel difference. Any way (css?) to make the image scale automatically according to the screen size?
Site url: http://www.imprero.com/wordpress/graffitx/
Thanks.
The background size must be contained so that it will automatically fit.
Insert this to the background you are talking about: "background-size: contain;"
Try this.
element{
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;
}

Responsive background image in twenty fifteen issue

I'm trying to make my background image responsive in the twenty fifteen theme, especially for mobile i.e. 360px by 640px. I've tried tons of CSS, but no dice. The div is body.custom-background I believe.
Here is the test site: test.justinhawleydesign.com
Thanks
Justin
You'll need max-width: 100% and position your background center center fixed.
It works best to put this on the html element as it's more reliably the full height of the browser. That said, body seems to be working fine for you here when I revised in the inspector.
body.custom-background {
background: url('http://test.justinhawleydesign.com/wp-content/uploads/2015/09/camera-green22.png') no-repeat center center fixed;
max-width: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

Background images that fill window?

I have a background image and I want to fill the entire background of my site. I use:
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
The image is 2000px x 2000px. The problem is, when the browser window is larger than 2000px you can see a white background. Is there a way to get the image to strech if the browser window is large than the image?
First of all avoid using such large images as background if you are just using it for background . You can do it like this dont put everything to cover .Just in style tag put these two and you will get it .
background-image:url('your image');
background-size: cover;
Quality of image may be disturbed if it expands too much but this works .
Try this:
background-size: 100% auto;
background-size: cover; seems to work for me both ways -- both shrinking an image to fill if it's larger than the element, or stretching the image to fill if it's smaller. Here's an example of a small image stretching to fill a larger div: http://jsfiddle.net/MRSallee/Q7STG/
I prefer using this:
background: url(../img/url.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;

CSS body background image fixed to full screen even when zooming in/out

I am trying to achieve something like this with CSS:
I'd like to keep the body background image fixed on fullscreen, this is sort of done by the following code:
body
{
background: url(../img/beach.jpg) no-repeat fixed 100% 100%;
}
Now I can verify the window is indeed filled up with that image, at least this works on my Firefox 3.6
However, it screwed up when I tried to zoom in/out (ctrl+-/+), the image just is stretched/shrinked as the page zooms.
Is there a better way of doing this purely with CSS? I didn't find a good property for the background-image.
Or should I start thinking about jQuery to manipulate the width and height on the fly? They were both set to 100% so I reckon that should work "as always" :(
Thanks for any suggestion in advance!
there is another technique
use
background-size:cover
That is it
full set of css is
body {
background: url('images/body-bg.jpg') no-repeat center center fixed;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Latest browsers support the default property.
I've used these techniques before and they both work well. If you read the pros/cons of each you can decide which is right for your site.
Alternatively you could use the full size background image jQuery plugin if you want to get away from the bugs in the above.
You can do quite a lot with plain css...the css property background-size can be set to a number of things as well as just cover as Ranjith pointed out.
The background-size: cover setting scales the image to cover the entire screen but may mean that some of the image is off screen if the aspect ratio of the screen and image are different.
A good alternative is background-size: contain which resizes the background image to fit the smaller of width and height, ensuring that the whole image is visible but may lead to letterboxing if the aspect ratios are different.
For example:
body {
background: url(/images/bkgd.png) no-repeat rgb(30,30,30) fixed center center;
background-size: contain;
}
The other options that I find less useful are:
background-size: length <widthpx> <heightpx> which sets the absolute size of the background image.
background-size: percentage <width> <height> background image is a percentage of the window size.
(see w3schools.com's page)
Add this in your css file:
.custom_class
{
background-image: url(../img/beach.jpg);
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
and then, in your .html (or .php) file call this class like that:
<div class="custom_class">
...
</div>
Here is the simple code for full page background image when zooming
you just apply the width:100% in style/css thats it
position:absolute; width:100%;
Use Directly like this
.bg-div{
background: url(../img/beach.jpg) no-repeat fixed 100% 100%;
}
or call CSS separately like
.bg-div{
background-image: url(../img/beach.jpg);
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

Resources