Background: url in CSS not working - css

I'm new to CSS and was hoping someone could help me understand what I'm doing wrong. I'm trying to get an image to show up but it seems that no matter what I do it refuses to display on my page. Can someone please explain to me what I'm doing wrong?
Image saved in: Users/NenaH77/assignment/images/sitebg.jpg.
Css file is saved under: Users/NenaH77/assignment/css/style.css
body{
background: url('../images/sitebg.jpg') no-repeat top top #31b8ea;
}
By having ../images I thought the image saved in the folder was suppose to go up 2 levels and into my css folder so I don't understand why my image isn't showing up :(

Your CSS background declaration is invalid:
top top should be top or top left or some other valid combination of positions.
Try :
body {
background: url('../images/sitebg.jpg') no-repeat 0 0 #31b8ea scroll;
}

You need should probably put the background color first.
body { background: #31b8ea url('../images/sitebg.jpg') no-repeat top }
Mr. Slayer gave you the right answer though.

To go up 2 levels do this
background: url('../../images/sitebg.jpg') no-repeat top top #31b8ea;

This will work. You can see the fiddle here.
body { background: url(../../img/image.jpg) no-repeat center center; background-size: cover;}
This will also take you up two levels...

I just ran into this same problem. What worked for me was putting the full path of the image from my pc, instead of from just inside the project folder.
So in this case use
body { background: url('C:/Users/NenaH77/assignment/images/sitebg.jpg')}
Instead of
body { background: url('../images/sitebg.jpg')}

Related

How do i make my main image appear in the background of my masthead and button section

I have tried to implement the following code but nothing happens
#masthead {
background: url('data05/mono/public_html/wp/wp-
content/themes/spacious/images/monostaff1024x512.png') no-repeat center;
background-size: cover;
}
I am having no luck. IS my file to path format incorrect?
There is a space in your url after the "wp-"
data05/mono/public_html/wp/wp-
content/themes/spacious/images/monostaff1024x512.png
Also the formatting seems off, see background property.

How to add image as background of block

Can someone help me to understand what am i doing wrong? Want to add an image at the top center but it doesn't show anything. Here is a css code.Thank you.
div.header {
background: url(photo/header.png) no-repeat ;
display: block;
width: 1002px;
height:178px;
}
try changing the path of the image like (../photo/header.png)
can u make a folder stucture?. is the html file and photo folder in same folder?
I think we need more information about the problem. There is maybe a typo in your code. If you use the background or background-image property, you have to use quotation marks. Like this: background: url('photo/header.png') no-repeat;

Background Image rendering issues in rails 4.1

I am having trouble understanding how to troubleshooting why my browsers(google chrome and safari) are ignoring the background image. I can see the url built correctly in the dev tools, however it is struck out (the important override still fails here too). Here is my code:
body {
background-image: image-url('blue.jpg') no-repeat center center fixed
}
the image is stored in app/assets/images.
As always, any help is greatly appreciated.
try removing image-url and just using url
body {
background-image: url('blue.jpg') no-repeat center center fixed
}
I ended up setting the image as a background instead of a background-image:
body {
background: asset_url('blue.jpg') no-repeat center center fixed;
color: ...
margin: ...
padding: ...
}
I do not understand why this works however.

css - background image not showing up

I feel retarted for even having to post something like this but for being a vet in css I have no idea why this time I can't get an image to show in the background of a div. Here is what I have
#leadarea {
background-image:(images/submarines-for-sale-at-seamagine.jpg);
background-repeat: no-repeat;
background-position:center;
height:360px;
width:1160px;
}
<div id="leadarea"></div>
I have triple checked my path to the image and its correct. In the same directory of the file I have an folder called "images" and the file to that image. If I type in the full url to that image in a browser I can see the image. Why is my div not showing that image?
The proper syntax is:
background-image:url('images/submarines-for-sale-at-seamagine.jpg');
Also notice that the path is relative to the .css file placement.
Put the url in your background-image
background-image: url("your-image-path.jpg");
Try this to optimize your background definition in one line:
#leadarea {
background: transparent url("http://1.bp.blogspot.com/-5PauJ-PHxns/UVjwME0X9YI/AAAAAAAAA4s/lsd9ZRsfCnE/s1600/coelho+escolha.jpg") no-repeat center;
// background: color url("your-image-path.jpg") repeat position;
height: 400px;
width: 400px;
}
Check the example here: http://jsfiddle.net/R5cJp/2/

IE 8, CSS-repeat-x and relative not working at all

I've got a big issue concerning the background of my header.
I've been tweaking the site for a few hours in IE, since the page is perfect in every other browser, however old they may be. But i'm totally losing my mind on IE 8, since my header-background (a .gif) simply won't repeat itself ONLY horizontally.
As said before, it's great in every other browser, even IE6,7 and 9, but in IE 8 the background just pastes itself over the whole site.
the css:
header{
position:relative;
height:615px;
background:url(/images/1paage-header-bg.jpg) repeat-x center top;
width:100%;
min-width:950px; }
I'd appreciate a little help here...
background:none;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='ImagePath',sizingMethod='scale');
background-repeat: repeat-x;
It's working in Internet Explorer 6.
Seeing how you've structured your site would definitely help.
But, often what is used for horizontally repeating header background is body.
http://jsfiddle.net/KMQJd/
Little clarification: Usually body is used if you are already using some sort of background image in html ( which i kinda asumed here.. ) But if you just have a background color and you want to use repeating image at top you should use html - html { background: #777777 url(image.jpg) repeat-x top left; }
I wonder if its the order of your position as first should come vertical and then horizontal.
background: url(image.jpg) repeat-x top center;
I have had the same problem, just check the syntax in IE8 every space is important, also check in firebug if the image loads? My bad syntax was:
background: #fff url(../img/bg_02.png)repeat-x top center;
correct one:
background: #fff url(../img/bg_02.png) repeat-x top center;
in my case the space was the problem. the top and center parameters are obsolete.
Repeat x does not work in IE 8. There no other alternative though
http://reference.sitepoint.com/css/background-repeat
Try setting background-repeat to repeat-x like this:
background-repeat:repeat-x;

Resources