Reputation: 605
Hi, I'm scratching my head over this one. I want to create a CSS gradient arrow like the one shown, and with the ability to define the fill of the red section as a percentage. The red block is just a solid colour.
From this JFiddle example I have made some progress on creating the green arrow, but the gradient on the triangle is in the wrong direction. I am still unsure of how to get the red block to fill up as a percentage of the green arrow. For example if the red portion is 90% I'm going to have to somehow create half a triangle. Help please :)
Example Code for the green arrow:
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%);
}
Upvotes: 3
Views: 930
Reputation: 2874
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%;
}
Upvotes: 1
Reputation: 730
Below the code seems to create an arrow.
Is it what you are looking for ?
div.a3 {
width: 100px;
height: 50px;
position: relative;
margin: 50px;
background: -webkit-linear-gradient(left, #1e5799 0%,#2989d8 100%);
background: -moz-linear-gradient(left, #1e5799 0%, #2989d8 100%);
}
div.a3:after {
z-index: -1;
content: "";
display: block;
position: absolute;
right: -75px;
top: -50px;
margin: 50px;
height: 50px;
width: 50px;
background: #000;
transform:rotate( -45deg );
background: -webkit-linear-gradient(135deg, #1e5799 0%, #2989d8 50%, #ffffff 50%, #ffffff 100%);
background: -moz-linear-gradient(135deg, #1e5799 0%, #2989d8 50%, #ffffff 50%, #ffffff 100%);
}
Upvotes: 0