gpt4 book ai didi

具有两个方向线性渐变的 CSS3

转载 作者:行者123 更新时间:2023-12-02 17:34:50 25 4
gpt4 key购买 nike

我的网站上有一个标题,目前使用线性渐变从一种颜色移动到另一种颜色。这是 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;
}

它从左边开始,稍微向右边改变颜色。我想同时从右边做同样的事情。我试图包括以下内容,但它只保留了两行之一:

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%);

它只保留第二个。知道如何解决这个问题吗?

最佳答案

您可以添加更多linear-gradient,方法是用逗号, 分隔它们。

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,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28052238/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com