我有一个用 Photoshop 设计的按钮。该按钮定义了渐变,我知道如何使用 Ultimate CSS Gradients Tool 生成它.
问题是按钮还有一个“颜色叠加层”,我不知道如何将其转换为 css 术语?!
更新:
好吧,澄清一下,我非常了解 CSS,我知道如何为元素设置样式。
我有这个渐变:
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2IzYjdiZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9Ijg1JSIgc3RvcC1jb2xvcj0iIzZhNzI3ZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, rgba(179,183,189,1) 0%, rgba(106,114,125,1) 85%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(179,183,189,1)), color-stop(85%,rgba(106,114,125,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(179,183,189,1) 0%,rgba(106,114,125,1) 85%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(179,183,189,1) 0%,rgba(106,114,125,1) 85%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(179,183,189,1) 0%,rgba(106,114,125,1) 85%); /* IE10+ */
background: linear-gradient(to bottom, rgba(179,183,189,1) 0%,rgba(106,114,125,1) 85%); /* W3C */
但就像我提到的,在 photoshop 中还定义了一个 Color Overlat,它使按钮有点暗,所以在 photoshop 中按钮看起来比在浏览器中更暗,所以我的问题是如何结合渐变和颜色叠加在一个 CSS 规则中,使按钮看起来与在 photoshop 中完全一样。
最佳答案
更新:
更好一点的按钮Demo
Demo带覆盖
只需为按钮声明一个类 .design
.design {
/* Gradient code goes here */
}
现在你可以像下面这样使用这个类了
<button class="design">Designed Button</button>
或
<input type="button" class="design" value="Designed Button" />
For the COLOR OVERLAY, you can wrap the button inside a div with
display: inline-block
andposition: relative
so that it will wrap the button appropriately and use another div which ispositioned absolute
inside thewrapper div
with a height and width defined as100%
and assign opaque background color usingrgba()
and define opacity as needed
此外,如果您希望 CSS 声明精确,您可以特别将 .design
类定义为 input[type=button].design
或 button .design
无论你使用什么,这样 .design
就不会应用于任何其他元素
关于css - 如何在 CSS 中模仿 Photoshop "Color Overlay",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15135929/