Reputation: 229
I am making responsive triangle(down arrow) with css. My problem is that I want to increase my triangle height downward But when I increase padding bottom it disturbs the triangle shape.
Here is my code :
.btna {
position: relative;
display: inline-block;
height: 50px;
width: 25%;
text-align: center;
color: white;
line-height: 50px;
text-decoration: none;
padding-bottom: 15%;
background-clip: content-box;
overflow: hidden;
}
.btna div {
content: "";
position: absolute;
top: 0px;
left: 0;
background: -webkit-linear-gradient(#d5adee, #fff); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#d5adee, #fff); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#d5adee, #fff); /* For Firefox 3.6 to 15 */
background: linear-gradient(#d5adee, #fff); /* Standard syntax */
padding-bottom: 50%;
width: 57.7%;
z-index: -1;
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: rotate(-30deg) skewX(30deg);
-ms-transform: rotate(-30deg) skewX(30deg);
transform: rotate(-30deg) skewX(30deg);
}
<div class="btna">
<div></div>
</div>
Upvotes: 3
Views: 126
Reputation: 1111
I presume that you want to keep the triangle within the bounds of its .btna class, correct?
The following code retains a triangle while also making it so that it has more height and stays responsive.
Replace transform: rotate(-30deg) skewX(30deg);
with
transform: rotate(-45deg) scale(1.4);
Skew can be very useful for making any triangle into a right triangle, but because we're all ready starting with one (the square with its overflow cut off), then it's not very helpful.
Upvotes: 3