Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Background-position Chrome

Ok so I have set a background-position property on an element through a class declaration. And for some reason chrome, and I'm assuming all webkit browsers, ignore the background-position property.

I have like so

.buttonholder {
background-position: -175px 0px;
}

and

<span class='buttonholder'>
<a href='index.php'>Home</a>
</span>

I took out the firebug type tool in chrome and for some reason the tag comes up like so:

<span class='buttonholder' style='background-position: 0% 0%; '>

Even though there is no specific style declaration inside the elements tag. Any advice would be greatly appreciated

Edit: Apparently people think I am trying to use this as a way to position the element. Which is false. I'm trying to position a background image.

like image 420
Anonymous Avatar asked Dec 22 '10 21:12

Anonymous


People also ask

What is background-position in CSS?

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 change the position of an image 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.

How do you put a background image on the right side in CSS?

You can position your background image in an editor to be x pixels from the right side. background: url(images_url) no-repeat right top; The background image will be positioned in top right, but will appear to be x pixels from the right. Save this answer.

How is background-position calculated?

The four-value syntax for background-position You combine length values with any of top/right/bottom/left keywords (not center). So for our example: background-position: right 20px bottom 10px; Using this, you can offset a background-image from any of the four corners of an element.


2 Answers

Add this:

background-position-x: -175px;
background-position-y: 0px;

Also see: http://code.google.com/p/chromium/issues/detail?id=57963

like image 74
Veda Avatar answered Sep 19 '22 06:09

Veda


In chrome, to solve this bug, you need to use percent in background position. When change position will works fine.

Hope its help

like image 27
Rene Souza Avatar answered Sep 19 '22 06:09

Rene Souza