CSS3具有两个方向的线性渐变 [英] CSS3 with linear gradient for two directions
本文介绍了CSS3具有两个方向的线性渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网站上有一个标头,该标头当前使用线性渐变从一种颜色转换为另一种颜色.这是CSS:
I have a header in my website which currently use a linear gradient to move from one color to the other. This is the CSS:
#top-header {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
z-index: 99999;
/* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(100%, #be2e26), color-stop(20%, #be2e26), color-stop(20%, rgba(22, 22, 22, 0)), color-stop(20%, rgba(22, 22, 22, 0)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #be2e26 100%, #be2e26 40%, rgba(22, 22, 22, 100) 100%, rgba(22, 22, 22, 100) 100%);
/* Chrome10+,Safari5.1+ */
/* Opera 11.10+ */
/* IE10+ */
background: linear-gradient(to right, #be2e26 30%, #be2e26 20%, rgba(22, 22, 22, 0) 50%, rgba(22, 22, 22, 0) 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#be2e26', endColorstr='#be2e26', GradientType=1);
/* IE6-9 */
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
它从左边开始,然后稍微改变颜色到右边.我想同时从右边做同样的事情.我尝试包括以下内容,但它仅保留以下两行之一:
It starts from the left and slightly change the color to the right. I want to do the same thing from the right at the same time. I tried to include the following, but it keeps only one of the two lines:
background: linear-gradient(to right, #be2e26 30%, #be2e26 20%, rgba(22, 22, 22, 0) 50%, rgba(22, 22, 22, 0) 100%);
background: linear-gradient(to left, #be2e26 30%, #be2e26 20%, rgba(22, 22, 22, 0) 50%, rgba(22, 22, 22, 0) 100%);
仅保留第二个.知道如何解决这个问题吗?
It keeps only the second. Any idea how to fix this?
推荐答案
您可以添加更多linear-gradient
,方法是用逗号分隔,
.
You could add more linear-gradient
s by separating them with a comma ,
.
background: <linear-gradient>, <linear-gradient>,...
#top-header {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100px;
z-index: 99999;
background: -webkit-gradient(linear, left top, right top, color-stop(100%, #be2e26), color-stop(20%, #be2e26), color-stop(20%, rgba(22, 22, 22, 0)), color-stop(20%, rgba(22, 22, 22, 0))), -webkit-gradient(linear, right top, top top, color-stop(100%, #be2e26), color-stop(20%, #be2e26), color-stop(20%, rgba(22, 22, 22, 0)), color-stop(20%, rgba(22, 22, 22, 0)));
background: -webkit-linear-gradient(left, #be2e26 100%, #be2e26 40%, rgba(22, 22, 22, 100) 100%, rgba(22, 22, 22, 100) 100%), linear-gradient(to left, #be2e26 30%, #be2e26 20%, rgba(22, 22, 22, 0) 50%, rgba(22, 22, 22, 0) 100%);
background: linear-gradient(to right, #be2e26 30%, #be2e26 20%, rgba(22, 22, 22, 0) 50%, rgba(22, 22, 22, 0) 100%), linear-gradient(to left, #be2e26 30%, #be2e26 20%, rgba(22, 22, 22, 0) 50%, rgba(22, 22, 22, 0) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#be2e26', endColorstr='#be2e26', GradientType=1);
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
<header id="top-header"></header>
这篇关于CSS3具有两个方向的线性渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文