http://jsfiddle.net/Zx836/
In the second box, notice how the arrow is in the same place. How can I make it flow with the div?
Using scroll right center
in the background
property works but I want to keep some padding right.
I'm also trying to avoid using 2 divs or the tag. Is this possible just via the .box
div?
First, set a background image using the background-image property. Next, set the background-repeat property to no-repeat . Then, write the fixed option for the background-attachment property. After that, apply the background-position property to the center center option and the background-size property to cover .
You can't really add margins to a background image, since it's not actually an element. A couple things you might try: If you've got a containing element just inside the body, you can apply the background image to this element and set margins on it.
The most common & simple way to add background image is using the background image attribute inside the <body> tag. The background attribute which we specified in the <body> tag is not supported in HTML5.
.right-align-background {
background-position: center right;
}
http://jsfiddle.net/Zx836/1/
You could also use background-origin: content-box;
if your you would like your background to line up with the padding you set on the element.
Something like this:
input.error {
background: no-repeat;
background-image: url('../images/field-error.png');
background-position: right center;
background-origin: content-box;
padding-right: 5px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With