Skip to main content

Bug Tracker

Side navigation

#13631 closed bug (duplicate)

Opened March 19, 2013 11:42PM UTC

Closed March 20, 2013 12:03AM UTC

Last modified March 20, 2013 05:19PM UTC

CSS "background" not reporting properly in certain browsers

Reported by: tegskywalker@hotmail.com Owned by:
Priority: undecided Milestone: None
Component: css Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

If an element has background settings set shorthand, it reports back in Chrome but Firefox and IE report an empty string. It wasn't working for my pages where I was looking to get the values of "background" for an element and even hand coding in the console gives the same results.

My CSS is as follows:

#logo { background:url('images/logo.jpg') no-repeat 0px 0px; float:left; width:200px; height:10px; display:inline; }

For example if I do this in Chrome, Firefox, or IE:

$('#logo').css('background');

Chrome reports:

"rgba(0, 0, 0, 0) url(/images/logo.jpg) no-repeat scroll 0px 0px / auto padding-box border-box"

Firefox and IE just report:

""

If I manually look for "background-image" or "background-position", all browsers report the same.

Is this intentional or a bug?

Attachments (0)
Change History (3)

Changed March 20, 2013 12:03AM UTC by gibson042 comment:1

component: unfiledcss
resolution: → duplicate
status: newclosed

Duplicate of #13421.

Changed March 20, 2013 12:04AM UTC by gibson042 comment:2

Further information from http://api.jquery.com/css/:

[Retrieval of] Shorthand CSS properties (e.g. margin, background, border) are not supported. For example, if you want to retrieve the rendered margin, use: $(elem).css('marginTop') and $(elem).css('marginRight'), and so on.

Changed March 20, 2013 05:19PM UTC by tegskywalker@hotmail.com comment:3

I do have one last thing though. When you try to get "background-position" with the CSS selector, it reports in IE9+, Chrome, and Firefox with the value but IE is blank. You have you use the non standard "background-position-x" and "background-position-y" to get those values. Do you think down the road if someone is using IE8 and below and they do "background-position" that jQuery can get the x and y values and combine them to give the same value as the newer browsers?