开发者

Stop Firefox rendering inline colours in rgb() form

I'm trying to write a JavaScript tool to work on items of a certain colour. On a test page, I set the colour using an inline style, to mimic the target pages, but when the page is rendered, the colour is specified using the CSS rgb() function.

The HTML tries开发者_运维技巧 to emulate the GMail container I want to change the background colour on. When I inspect the element in Firebug, the colour is displayed as rgb().

<div style="width: 100%; height: 30px; border: 1px solid black; 
    background: #6694E3 none repeat scroll 0 0;">    
</div>

How can I stop the colour being converted from #6694E3 to rgb(102, 148, 227)?


Check out this script to convert rgb() notation to hex.


This is not a conversion, it's just a different way of expressing the same thing. If you want to check for a particular colour, you will have to first express it in rgb format, then do the check. As far as I am aware, the css value returned for a DOM element is whatever it is - you cannot change the format.


You are probably looking at the value through firebug, which translates all colors to RGB form in the console. This does not mean it changed in the DOM.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜