So I am having just a small issue with a site that I am modifying for a client: http://gator3094.hostgator.com/~sunhome/staging/.
As you can see, the background image that I am putting around the <header></header> tags is not stretching the full height of the div.
Here is a link to my CSS file (everything else is just stock Foundation Framework): http://gator3094.hostgator.com/~sunhome/staging/wp-content/themes/sunpower_theme_sunsolar/library/css/custom.css
Here is also the CSS code that I am using for that particular section of the site:
header {
background: url('http://gator3094.hostgator.com/~sunhome/staging/wp-content/uploads/home-bg2.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I have done these full-width cover backgrounds with CSS3 a million times, but I have absolutely no idea why this time the image won't cover the entirety of that div.
Hopefully it's just a super simple fix. I would really appreciate any and all help.
Your issue is because of the lack of appropriate cropping of your background image.
Try this with your header tag:
header { background: black;}
You'll see that the background takes up the appropriate dimensions of the div. The reason white space is showing is because your background image has a lot of extra transparent space around the image. So the background is repeating appropriately, you just need to crop it so it will show the part of image you want.
Still dont belive me?
Try replacing it with this:
header { background: url("http://placekitten.com/1800/950");}
Related
I have made a background image, 1366px wide and 768px high, which I want to use as background for the main page of my website.
I have each page of my website divided in sections, using the FullPage plugin.
This is the main page so I'm using just the first section.
What I've tried so far is adding this CSS code to the #first section of my main page:
#first{
width: 500px;
height: 500px;
background-image: url(images/ClanshnowXmasEventSmall.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Unfortunately the image gets displayed just partially. In fact it's a little shorter than it actually is.
I read the documentation for the background-size attribute, and at the cover attribute it says:
Scale the background image to be as large as possible so that the background area is completely covered by the background image. Some parts of the background image may not be in view within the background positioning area
So basically how can I make my background-image fit the screen size? Considering the mobile side I think it would be better to fit just the width of it. I'm open for suggestions and help!
Take a look over here: https://www.google.be/amp/s/css-tricks.com/perfect-full-page-background-image/amp/?client=safari
Good luck!
This is such a strange issue - I'm trying to add in a responsive background image to a really simple site, and I can see that image flicker on the screen while the page loads, however when the page load is complete the image disappears and I'm left with a white background.
Here's the css:
body {
background: url('#') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Here's the site.
The problem is that all your elements have an opaque background-color. The image is there, it is just covered up by everything else. Remove the backgrounds from all the child elements, or use a rgba color.
This is something that your theme is doing, using Javascript. If you look in here, you will see the line
`$("#main-wrapper").animate({ opacity: 1 }, 750);`
This is run when the page initialises, and causes the opacity of themain-wrapper element to animate it's opacity, causing the fade you are seeing.
Your options are:
Change your theme to a different one, or
Create a child theme and then edit the main.js file to remove the offending line. This has the advantage that you can keep all the theme, and your change will be protected from theme updates.
the problem is your every <div> has background and you are applying background image on body, Applying any thing on body will not help you as i see you buy this theme from someone you need to ask them how to add background on this site.
Try bootstrap. You can add a background image to a container
<div class="container background">
</div>
your css
.background {
................
}
I have a problem with html and css.
Today, for the first time, I've tried to make a page with a big image for the background.
I'm using foundation framework, and I'm stuck on one thing. As we know foundation is a adaptive framework and when I re-size my browser, I've got a bug.
You can see it on my screenshot: https://imgurhd.ru/i/270a.jpg (also here you can find my css).
I need to make the text and image under menu vertically centered on any screen size.
I'm using position relative with a percent value, as you can see. So please help me to find where is the problem.
You can set the background size to cover.
Cover
This keyword specifies that the background image should be scaled to be
as small as possible while ensuring both its dimensions are greater than or
equal to the corresponding dimensions of the background positioning area.
html {
background: url(/*YOUR IMAGE HERE*/) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
This is supported in most recent browsers
I'm facing this trouble for quite some time now, have tried n number of options but still no luck.
I have this background image :
Which I want to make as the background of my website. I added it as a full sized background, but I don't know why it always gets resized and becomes something like this.
Here's my css code for the background image.
body
{
background: url('../images/home.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I'm really unsure how to fix this! Please guide me in the correct way.
The background-size: cover property in CSS3 stretches your images to fit the background of the element you have specified, which in this case your body.
Edit: As others have mentioned, using background-size: contain would give you the most desirable result as it is defined by the following:
contain
This keyword specifies that the background image should be scaled to be as large as possible while ensuring both its dimensions are less than or equal to the corresponding dimensions of the background positioning area.
The link below also has other properties that may give you your desired results:
Source:https://developer.mozilla.org/en-US/docs/Web/CSS/background-size
Try to use background-size:contain instead of background-size:cover. Maybe that is more appropriate.
If you want to keep your image in proportion you would want to use
background-size: contain;
However the issue with this is it will keep the background in proportion, so if your window is not the same proportions you will have white space around. Building off #Sebastien 's fiddle I can show you what I mean -
http://jsfiddle.net/j0n19rw5/5/
You could try re-sizing the image itself to work better with contain.
But if you want it to cover the background you would probably be best using cover. One trick is to crop the image to the space (if you know a general sizing).
You can get away without stretching it too much with a method like this one :
https://jsfiddle.net/r3qpe4dm/1/
But it will still cut off your image at smaller sizes.
To be sure, split the background property for each sub-attribute :
body
{
background-image: url('http://i.stack.imgur.com/ZQinh.jpg');
background-position: center center;
background-attachment: fixed;
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
http://jsfiddle.net/Paf_Sebastien/j0n19rw5/1/
Edit:
Add this to your CSS since your HTML/body seem to have a low height:
html, body {height: 100%;}
So I have tried to get rid of this white space to the right of my website for ages now. I've tried all the overflow-x: hidden rules but none of them seem to work.
I have ruled it down to when I remove:
(div id="content5" style="position:absolute;")
(img style="width:175px; height:175px;" src="Images/Graphic.jpg")
(/div)
from the html file then the white space goes away. How do I put the picture on my web page without getting the white space? Don't worry I am using angle brackets for my html.
You can view my website here.
CSS:
view code here
HTML:
view code here
Make the width of the #content5 element set to the pixel width of the image:
#content5 {
width:175px;
}
Right now, the width is set to 50%. But that essentially sets it to 50% of the width of the parent element, which is the whole page. If you look in the inspector, the divs containing all of your images are much larger than they need to be because of this.
EDIT: Included inspector image of Chrome session
#Daniel Ravens if you insert the following code it should fix your problem:
html {
background: url(Images/FrontCover.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
This code basically stretches everything on the page to make it fit I got this code from the following site:
CSS Tricks