element background image won't render - css

I'm trying to create a block quote like in the image below:
http://www.norrislakevillas.com/images/block-quote-sample.png
The quotation marks sit in the bottom right corner of a 50 X 45 px transparent PNG image with 10px of spacing on the top and left.
The element is rendering correctly with the exception of the background image, it just won't show up.
CSS Code:
#block_quote{
float:left;
width:400px;
background:#f7f7f7;
background-image:url(images/quote-top.png) left top no-repeat;
margin:50px 0 100px 53px;
border:1px solid #ccc;
}
#block_quote p{
font:italic 14px segoe ui, arial, sans-serif;
color:#5f5f5f;
line-height:1.4em;
margin:0;
padding:20px 15px 20px 60px;
}
Any ideas why the image isn't rendering?
Thanks

Your image path needs to be relative to the CSS file. Also it's just background, not background-image if your using all the declarations in one line and the order at the end is no-repeat top left.
background: url(images/quote-top.png) no-repeat top left;

background is a "shorthand property" that sets all background properties, including the url of the image. The way you write it, it does not specify an image, only a color.
So don't mix up background and the individual background properties like background-image. It should be either
background:#f7f7f7 url(images/quote-top.png) no-repeat left top;
or
background-color:#f7f7f7;
background-image:url(images/quote-top.png);
background-repeat:no-repeat;
background-position:left top;
but not any mix of these; that will confuse the browser.

Related

Background image/position rendering differently on iPad

I have a div which has one of two background positions for a sprite background image depending on the class set for the div in a php script.
The CSS, which is below, works fine on standard browsers, but on the iPad I am not seeing the same. Instead I see more of the background image than I want to. As you can see from the image below, rather than just seeing one star, I am seeing part of another star too.
How can I get the background position/image looking right on the iPad?
.normal, .favourite {
width:18px;
height:17px;
margin-right: 4px;
border:none;
cursor: pointer;
display:inline-block;
vertical-align: middle;
background-color:transparent;
background-repeat: no-repeat;
}
.normal {
background-image: url('/images/playlist_sprite.png');
background-position: left bottom;
}
.favourite {
background-image:url('/images/playlist_sprite.png');
background-position: right bottom;
}
Rather than defining the background position using left/right/bottom try defining it exactly using pixels.
e.g.
background-position: XXpx XXpx;
Also, make sure that both those images in your sprite are exactly 18px by 17px as that is what the class is saying the image size will be.

How do you make a background repeat y start lower?

I'm curently workign on this page and I'm trying to make the background repeat-y from a certain height but to no avail. If you look at the link's background (bottom area); you'll see that it leaves a an ugly space there, which is ugly. The CSS is as show below
body {
font-family:Calibri;
font-size: 16px;
margin: 0px;
padding: 0px;
background-color: #000;
background-image: url(images/bg.png);
background-repeat: repeat -200px 0px;
}
There's no way I'm aware of that makes the repeat skip some pixels. If I were you I would split them so the background-image of the body would be what the majority of it is now without the top. And then I would add a div to the top with these settings:
<div id="upperpart"></div>
in css:
#upperpart{
background-image: url(whatever it is);
width:100%;
height:how high it is
background-repeat: repeat-x;
margin-bottom: minus its height; <-- this will make everything below this div get ontop the div
}
After some mathematical thinking and experiments, the line of code below did the magic. I had to also watch where to cut it off with -1530px. Make sure you use the same background you used with the body tag.
html {
background: url(images/bg.png) repeat 0px -1530px;
}

background positioning using repeat-y

I have a background image, that is simply a wrapper for the main content of my page.
I have set this image a background image like:
#background {
background: url("../image/bg.png") repeat-y 133px 50px;
color: #000000;
font-family: Arial,Helvetica,sans-serif;
margin: 0;
padding: 0;
}
I would have thought that this would position the image 133px from the left and 50px from the top, but it is flush against the top of the browser.
Can anyone shed any light on why this is doing this?
Thanks
Can this kind of position be done when the image has repeat-y?
Thanks
You are using repeat-y so the background is repeated vertically, both down and up. The value you specified - 50px - is the place where the original background starts, but if your background has a height of 50px, you will not notice the difference as it is repeated above it as well.

Positioning a background image with CSS

Is there a way to precisely position a background image with CSS? Code:
.content h2.productSpotlight {background:url(/images/spotlight.jpg) no-repeat; padding-left: 35px;}
I want to be able to move the image around so its more flush with the H2
Thanks
Yes, you can give an offset position for the background property, for example:
background: url(/images/spotlight.jpg) no-repeat 10px 5px;
This will shift the background image 10px from the left corner and 5px from the top. You can also use negative values to shift in the opposite direction.
sure, the background properties include background-position. You can specify it separately as
background-position:20px 20px;
or as part of the combined syntax like
background:url(/images/spotlight.jpg) no-repeat 20px 20px;
See the reference at MDC.

CSS positioning of background image

html {
background: #9c9c9c url(../images/bg-bottom.jpg) center top;
}
body {
border-top:2px solid #fecd2a;
background:#9c9c9c url(../images/bg.jpg) repeat-x center bottom;
}
I need bg.jpg which is the large background with the black gradiantat the top, to be at the top and for the bg-bottom.jpg to be repeated at the bottom. How come this doesn't work, is there and easier way? Apart from creating one long image.
http://fluroltd.com/clients/harveys/latest-news/
Looks like you need to switch around your positioning and use a transparent background for the body tag:
html {
background: #9c9c9c url(../images/bg-bottom.jpg) center bottom
}
body {
border-top:2px solid #fecd2a;
background: transparent url(../images/bg.jpg) repeat-x center top;
}
Your CSS on the body should be
background: url("../images/bg.jpg") repeat-x scroll #9C9C9C;
I don't think adding a background to your HTML tag is going to get you anywhere. If I were you I would just make one super long, narrow-width image that will not possibly be exceeded by the length of your page. You can't have multiple BGs without using CSS3, which I personally wouldn't recommend.

Resources