I want to achieve something like this
How do I put this triangle css
.triangle{
width: 0;
height: 0;
border-style: solid;
border-width: 21px 42px 21px 0;
border-color: transparent #eeeeee transparent transparent;
line-height: 0px;
_border-color: #000000 #eeeeee #000000 #000000;
_filter: progid:DXImageTransform.Microsoft.Chroma(color='#000000');
}
to make a triangle at the end of my tab? DEMO http://jsfiddle.net/p69qfqsx/
Add a triangle to end of div You can use :after selector to add a style to the end of a div. When adding an arrow to bottom we need to keep the top border and make other borders transparent. In this div, the width has been set as 100px. Then the left and the right border have to be half of size of the div.
The concept is to create a box with no width or height. The width of the border determines the Triangle's actual width and height. The bottom border of an up-arrowed triangle, for example, is colored, while the left and right borders are transparent, forming a triangle.
New CSS for the list:
ul{
width: 200px;
border: 1px solid #ccc;
}
li a{
background-color: #fff;
padding: 5px 10px;
display: block;
position: relative;
color: #666;
text-decoration: none;
}
li a:hover, li.active a{
background-color: #eee;
}
li a:hover:after, li.active a:after{
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 10px solid #fff;
/* background-color: #ddd; */
content: '';
position: absolute;
right: -2px;
top: 0;
}
https://jsfiddle.net/p69qfqsx/2/
Tested just for chrome hope it helps.
Here's the codes I modify for little change:
li a:hover:after{
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 12px solid transparent;
border-right: 10px solid #fff;
/* background-color: #ddd; */
content: '';
position: absolute;
right: -2px;
top: 1;
}
I just remove li.active a:after
to let pointer makes it. DEMO
But I prefer using what @Andre Morales suggest since it works here.
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