gpt4 book ai didi

用渐变百分比填充的 CSS 箭头

转载 作者:行者123 更新时间:2023-11-28 10:18:02 27 4
gpt4 key购买 nike

Arrow

嗨,我正在为这个问题挠头。我想创建一个如图所示的 CSS 渐变箭头,并能够将红色部分的填充定义为百分比。红色 block 只是纯色。

从这里JFiddle示例 我在创建绿色箭头方面取得了一些进展,但三 Angular 形上的渐变方向错误。我仍然不确定如何让红色 block 填充为绿色箭头的百分比。例如,如果红色部分是 90%,我将不得不以某种方式创建半个三 Angular 形。请帮助:)

绿色箭头的示例代码:

div.a3 {
width: 100px;
height: 50px;
position: relative;
margin: 50px;

background: -webkit-linear-gradient(top, #99c739 0%,#4eb739 100%);
background: -moz-linear-gradient(top, #99c739 0%, #4eb739 100%);
}

div.a3:after {
z-index: -1;
content: "";
display: block;
position: absolute;
right: -75px;
top: -50px;
margin: 50px;
height: 50px;
width: 50px;

-webkit-transform:rotate( -45deg );
-moz-transform:rotate( -45deg );
transform:rotate( -45deg );

background: -webkit-linear-gradient(135deg, #99c739 0%, #4eb739 50%, #ffffff 50%, #ffffff 100%);
background: -moz-linear-gradient(135deg, #99c739 0%, #4eb739 50%, #ffffff 50%, #ffffff 100%);
}

最佳答案

div{
width: 200px;
height: 100px;
margin: 50px 0;
position:relative;
background: #d72200;
background: -moz-linear-gradient(left, #d72200 0%, #d72200 20%, #9ac739 20%, #6bbe39 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#d72200), color-stop(20%,#d72200), color-stop(20%,#9ac739), color-stop(100%,#6bbe39));
background: -webkit-linear-gradient(left, #d72200 0%,#d72200 20%,#9ac739 20%,#6bbe39 100%);
background: -o-linear-gradient(left, #d72200 0%,#d72200 20%,#9ac739 20%,#6bbe39 100%);
background: -ms-linear-gradient(left, #d72200 0%,#d72200 20%,#9ac739 20%,#6bbe39 100%);
background: linear-gradient(to right, #d72200 0%,#d72200 20%,#9ac739 20%,#6bbe39 100%);
}
div:after{
content:'';
width: 100px;
height: 100px;
position: absolute;
left: 100%;
top: 0;
background: #4eb739;
background: -moz-linear-gradient(45deg, #4eb739 0%, #6bbe39 50%, #6bbe39 100%);
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#4eb739), color-stop(50%,#6bbe39), color-stop(100%,#6bbe39));
background: -webkit-linear-gradient(45deg, #4eb739 0%,#6bbe39 50%,#6bbe39 100%);
background: -o-linear-gradient(45deg, #4eb739 0%,#6bbe39 50%,#6bbe39 100%);
background: -ms-linear-gradient(45deg, #4eb739 0%,#6bbe39 50%,#6bbe39 100%);
background: linear-gradient(45deg, #4eb739 0%,#6bbe39 50%,#6bbe39 100%);
-moz-transform: scale(1) rotate(45deg) translate(0px, 0px) skew(0deg, 0deg);
-webkit-transform: scale(1) rotate(45deg) translate(0px, 0px) skew(0deg, 0deg);
-o-transform: scale(1) rotate(45deg) translate(0px, 0px) skew(0deg, 0deg);
-ms-transform: scale(1) rotate(45deg) translate(0px, 0px) skew(0deg, 0deg);
transform: scale(1) rotate(45deg) translate(0px, 0px) skew(0deg, 0deg);
z-index: -2;
margin: 0 0 0 -50px;
}
div:before{
content:'';
position:absolute;
top: 0;
right: 0;
height: 100%;
padding: 22px 0;
z-index: -1;
background: #fff;
margin: -22px 0;
width: 100%;
}

关于用渐变百分比填充的 CSS 箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18058574/

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