Click here to Skip to main content
15,889,833 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi All,

My requirement is to assign a decimal values to rgb(a,b,c) in css.
CSS
#firstDiv{ position:absolute; background-color:rgb(222.34,123.456,333.456}

How to do it? rgb() is not considering decimal values,only integer part it is accepting.

Is there any way to do this in HTML 5 or by JavaScript?

Thanks for your suggestions in advance... :)

--Avinash
Posted
Updated 8-Jul-13 19:03pm
v2

1 solution

RGB are bytes (0-255) so you can't assign decimals to them they will get rounded to the nearest integer anyway.
 
Share this answer
 
Comments
Avinash6474 9-Jul-13 1:29am    
Thanks for your suggestion
Is there any other way to show the decimal combination in html,javascript ?
enhzflep 9-Jul-13 1:46am    
Why would you wish to do such a thing?
Colours on the pc monitor are 24bit - I.e there are 256 combinations each of R, G and B. You _cant_ have non-integer values, simple as that.

16.7 million colours isn't enough for you?
enhzflep 9-Jul-13 1:45am    
Edit: posted to wrong person. Sorry.
Mehdi Gholam 9-Jul-13 3:25am    
:)
Sergey Alexandrovich Kryukov 9-Jul-13 2:09am    
Of course, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900