I have a div and I need to give it an angular point. The height will vary based on its content so using pseudo content and borders like in the article below wont work.
http://css-tricks.com/snippets/css/css-triangle/
As this is a progressive enhancement I only need to support modern browsers.
The idea is a box with zero width and height. The actual width and height of the arrow is determined by the width of the border. In an up arrow, for example, the bottom border is colored while the left and right are transparent, which forms the triangle.
If height: auto; the element will automatically adjust its height to allow its content to be displayed correctly. If height is set to a numeric value (like pixels, (r)em, percentages) then if the content does not fit within the specified height, it will overflow.
An alternate answer, using gradients and pseudo elements
#one {height: 100px;}
#two {height: 200px;}
.corner {
width: 100px;
background-color: green;
margin: 10px;
position: relative;
}
.corner:after, .corner:before {
content: "";
position: absolute;
left: 100%;
width: 40px;
height: 50%;
}
.corner:before {
top: 0px;
background: linear-gradient(to top right, green 50%, transparent 51%);
}
.corner:after {
bottom: 0px;
background: linear-gradient(to bottom right, green 50%, transparent 51%);
}
<div id="one" class="corner"></div>
<div id="two" class="corner"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With