简体   繁体   English

有什么办法用颜色填充按钮背景的一半吗?

[英]Is there any way to fill half of a buttons background with a color?

Is there any way to fill half of a buttons background with a color? 有什么办法用颜色填充按钮背景的一半吗?

Like: 喜欢:

|BLUEBLUEBLUE REDREDREDRED|

Yes, you can do this in CSS with gradient backgrounds. 是的,您可以在带有渐变背景的CSS中执行此操作。

background-image: linear-gradient(left , rgb(255,0,0) 50%, rgb(0,0,255) 51%);
background-image: -o-linear-gradient(left , rgb(255,0,0) 50%, rgb(0,0,255) 51%);
background-image: -moz-linear-gradient(left , rgb(255,0,0) 50%, rgb(0,0,255) 51%);
background-image: -webkit-linear-gradient(left , rgb(255,0,0) 50%, rgb(0,0,255) 51%);
background-image: -ms-linear-gradient(left , rgb(255,0,0) 50%, rgb(0,0,255) 51%);

background-image: -webkit-gradient(
    linear,
    left bottom,
    right bottom,
    color-stop(0.5, rgb(255,0,0)),
    color-stop(0.51, rgb(0,0,255))
);

Use this site to customize it for your needs: http://gradients.glrzad.com/ 使用此网站可以根据您的需要对其进行自定义: http : //gradients.glrzad.com/

And here's a fiddle: http://jsfiddle.net/GNCRL/ 这是一个小提琴: http : //jsfiddle.net/GNCRL/

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

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