Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Position a CSS background image x pixels from the right?

Tags:

css

I think the answer is no, but can you position a background image with CSS, so that it is a fixed amount of pixels away from the right?

If I set background-position values of x and y, it seems those only give fixed pixel adjustments from the left and top respectively.

like image 989
Doug Avatar asked Jul 07 '10 17:07

Doug


People also ask

How do I move a background image to the right in CSS?

Give it a shot. Essentially, background-position: 90% 50% will make the right edge of the background image line up 10% away from the right edge of the container. Create a div containing the image. Explicitly set the position of the containing element position: relative if not already set.

Which CSS property is used when we want to position the background image in the right at the top of the Web page?

The background-position CSS property sets the initial position for each background image. The position is relative to the position layer set by background-origin .

How do I apply a background-position in CSS?

The background-position property sets the starting position of a background image. Tip: By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally.

How do I place an image in a specific position in CSS?

You can easily position an image by using the object-position property. You can also use a bunch of other ways like float-property that will be discussed further in this article. Methods: object-position property: Specify how an image element is positioned with x, y coordinates inside its content box.


1 Answers

background-position: right 30px center; 

It works in most browsers. See: http://caniuse.com/#feat=css-background-offsets for full list.

More information: http://www.w3.org/TR/css3-background/#the-background-position

like image 174
Steven Mouret Avatar answered Oct 19 '22 07:10

Steven Mouret