简体   繁体   English

如何在一个div背景中嵌套颜色?

[英]How to make nested colors in one div background?

How I can put multiple nested colors (or 2 colors precisely) to a div in css? 如何在CSS中将多个嵌套的颜色(或精确地2种颜色)放置到div中? If it's possible to do that, how I can specify the nesting form, as percentage of each color, position, etc? 如果可能的话,如何指定嵌套形式,如每种颜色,位置等的百分比?

I mean the gradients, to make a background like this: 我的意思是渐变,以使背景像这样:

在此处输入图片说明

You can do a 50/50 background if that's what you mean, using gradient, eg: 如果这就是您的意思,则可以使用渐变来做50/50背景,例如:

background: -webkit-gradient(linear, left top, right top, color-stop(50%,#000000), color-stop(50%,#333));

Or for a full gradient, eg: 或完整的渐变,例如:

-webkit-gradient(linear, left top, left bottom, color-stop(0%,#00b7ea), color-stop(100%,#000ed8)); 

Which is pretty straight forward, you just have to add the start and finish color. 这很简单,您只需添加开始和结束颜色。 Also, I'm saving space above but you should of course use -o-linear-gradient, -ms-linear-gradient, linear-gradient as well if you want to be supported on all browsers). 另外,我在上面节省了空间,但是如果要在所有浏览器上都支持,则当然也应使用-o-linear-gradient,-ms-linear-gradient,linear-gradient)。

There are also tools available to help you out: 还有一些工具可以帮助您:

http://www.colorzilla.com/gradient-editor/ http://www.colorzilla.com/gradient-editor/

You can use the RGB colors in order to choose one specific color: 您可以使用RGB颜色以选择一种特定的颜色:

background-color:rgb(255,255,255)

and playing with the values. 和玩的价值观。 you can also use color codes: 您还可以使用颜色代码:

background-color:#FF0F00

That is how you can reach a specific color (which is combined from two different ones). 这样便可以达到特定的颜色(由两种不同的颜色组合而成)。 I don't know of any ways to nest them. 我不知道如何嵌套它们。

If you would like to read more about the subject you can read about it here: http://www.w3schools.com/cssref/css_colors.asp 如果您想了解有关该主题的更多信息,可以在这里阅读: http : //www.w3schools.com/cssref/css_colors.asp

Good luck :) 祝好运 :)

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

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