I want to use background image and color for the same element but id doens't work even I use the css like this question
here's my css http://jsfiddle.net/xdkwB/
I want to use background image and color for the same element but id doens't work even I use the css like this question
here's my css http://jsfiddle.net/xdkwB/
Your CSS is working correctly, both the image and background colour sit within the one container so because they're the same colour, you can't actually see the arrow.
The best way to solve this is to use an outer div that wraps your header element, like so:
<div class="outer"><h1></h1></div>
And then style with appropriate CSS:
div {
float: right;
width: 198px;
background-image:url(http://s14.postimage.org/nitv9x7ct/top_Arrow.png);
background-position: 0px;
background-repeat: no-repeat;
margin-top:21px;
}
h1{
color:white;
font-size: 170%;
font-weight: normal;
font-family: arial;
width:189px;
height:33px;
line-height: 33px;
background-color: #b21f23;
float:right;
}
So to clarify, the outer div is slightly larger and contains the background image aligned to the left and then the header fills all remaining space with the background colour.
I don't think you can get your desired result with just one element styling.
You would either need to have the background-image
outside of the element, which is not possible.
Or you would need the background-color
to not fill all of the element, which is also not possible
The best option IMO, would be to have two elements with a background-image
in the first, and background-color
in the second
Example with text:
Example floated right:
try this
background: url(http://s14.postimage.org/nitv9x7ct/top_Arrow.png) no-repeat left center #b21f23;
this will add the background image and everything else will be your background color
You've set the background colour to the same colour as the image. So it's there, you just can't see it because it blends in.
You're arrow is the same color as te background. You can positioning the background with background-position
and with a negative left value it become outside the box: