admin管理员组文章数量:1293508
I want to add a caret symbol (down arrow or V) next to a menu item which has sub menu items. I know that it can be achieved using bootstrap. But, I can't update my custom css with bootstrap css as it would bee messy.
I'm happy to integrate only a part of bootstrap if that is going to work.
Please suggest me a solution asap.
I want to add a caret symbol (down arrow or V) next to a menu item which has sub menu items. I know that it can be achieved using bootstrap. But, I can't update my custom css with bootstrap css as it would bee messy.
I'm happy to integrate only a part of bootstrap if that is going to work.
Please suggest me a solution asap.
Share Improve this question asked Apr 24, 2015 at 1:06 KiranDKiranD 4513 gold badges7 silver badges20 bronze badges 2- show us what have you tried using relevant code – nicholaswmin Commented Apr 24, 2015 at 1:12
- @NicholasKyriakides, I'm not a css expert. I tried this.. .menu-parent a:after { width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 20px solid #f00; }. It didn't work. – KiranD Commented Apr 24, 2015 at 1:18
2 Answers
Reset to default 6You can try be using pure CSS to achieve a triangle:
Markup:
<div class="triangle"></div>
Style:
.triangle {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid black;
}
As result, you have a solid down arrow that you can use. If you want to go beyond, you can override this property with another similar triangle over it and make an exactly caret in a "V" format:
Markup:
<div class="triangle">
<div class="over-triangle"></div>
</div>
Style:
.triangle {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid black;
}
.over-triangle {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid white;
position: relative;
top: -10px;
left: -5px;
}
This way you can get the exact form of a caret:
You can apply it to another element by making the triangle display: inline-table
to align to the same line.
Now, it goes to you implement it on links!
If you are looking for easy symbol intergrations, I would suggest font-awesome if you want to avoid bootstrap.
http://fortawesome.github.io/Font-Awesome/
本文标签: javascriptHow do I add a caret (down wards) using CSS next to link (anchor tag)Stack Overflow
版权声明:本文标题:javascript - How do I add a caret (down wards) using CSS next to link (anchor tag)? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741580135a2386520.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论