当前位置: 动力学知识库 > 问答 > 编程问答 >

html - How to set just a percentage of a color in CSS?

问题描述:

I have some GUI guidelines where these color are specified:

text-color: #000 87%

background-color of the container: #000 20%

How can I apply those requirements in CSS?

I have read this post:

http://stackoverflow.com/a/12021283

But it didn't help me.

Thanks in advance!

网友答案:

Use RBGA:

text-color: #000 87%

would translate to:

color: RGBA(0,0,0,.87)

This is assuming they are asking for a percentage of opacity.

If, on the other hand, they are asking for a tint, that's a bit more difficult to handle. Not so much with black (as that translates to varying shades of gray) but mostly impossible with color as it would depend on which color model you are using to calculate the tint value. So, if they are asking for a completely opaque tint, tell whoever spec'd out the colors that they need to give you precise RGB or Hex values.

网友答案:

The above answer is the correct one if you're looking for colors with a bit of transparency.

This is a really great introduction to rgba:

http://css-tricks.com/rgba-browser-support/

Black is pretty easy to convert: #000 >> rgba( 0 , 0 , 0 , 0 )

This is a great tool if you have other hex values you need to convert:

http://www.hexcolortool.com/

网友答案:

You need first to convert hex code to rgb by using the tool below ...

hex to rgb

and then using this code in css color: rgba(r,g,b,transparent value);

example for black color: rgba(0, 0, 0, 87);

分享给朋友:
您可能感兴趣的文章:
随机阅读: