简体   繁体   English

如何使用十进制值设置CSS RGB颜色?

[英]How to set CSS RGB colors using decimal values?

I'm in new to HTML/CSS. 我是HTML / CSS的新手。 I can see that there are various ways of setting color code in a CSS style description ie by name eg yellow or by hex code #ffff00 . 我可以看到在CSS样式说明中有多种设置颜色代码的方法,即通过名称(例如yellow或通过十六进制代码#ffff00 I see there are also decimal equivalents of each color eg yellow has decimal equivalent as 255,255,0 but applying the below style on my body element has no effect at all: 我看到每种颜色也有十进制等效项,例如,黄色的十进制等效值为255,255,0但对我的body元素应用以下样式完全无效:

My CSS: 我的CSS:

body {
background-color: 255,255,0;
color: black !important;
}

Can someone help me on this? 有人可以帮我吗?

Like this 像这样

body {
    background-color: rgb(255,255,0);
}

To add opacity, use rgba . 要增加不透明度,请使用rgba Where 1 is 100% opacity. 其中1是100%不透明度。

body {
    background-color: rgba(255,255,0, 1);
}

rgba(255,255,0,1) To add opacity, use rgba. rgba(255,255,0,1)要添加不透明度,请使用rgba。 Where 1 is 100% opacity. 其中1是100%不透明度。

 .body { background-color: rgb(255,255,0); color: black !important; padding:25px; } 
 <div class="body"></div> 

you need to add this rule to your css rgb(0,0,0) or rgba(0,0,0,0.5) to opacity. 您需要将此规则添加到css rgb(0,0,0)rgba(0,0,0,0.5)中以提高透明度。

body {
    background-color: rgb(255,255,0);
    color: rgba(0,0,0,0.7);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM