What is this CSS active menu style with triangle c

2019-06-02 17:04发布

In the following picture, I have mocked up a CSS active menu styling I would like to find examples of, and hopefully replicate.

Triangle active menu

You will notice there is a triangle highlighting the active menu, and it can appear bold too.

Question 1. What is this "active menu triangle style" actually called? So I can find CSS examples of it.

Question 2. Where can I find examples of this?

标签: css geometry
5条回答
欢心
2楼-- · 2019-06-02 17:53

The shape is called a CSS polygon. Tantek Celik was one of the first to write about the technique in 2001. The design pattern is called a location-based breadcrumb.

查看更多
唯我独甜
3楼-- · 2019-06-02 17:57

All done through css classes like so:

html

<ul>
    <li><a href="#">Menu Item 1</li>
    <li><a href="#" class="selected">Menu Item 2</li>
    <li><a href="#">Menu Item 3</li>
    ....
</ul>

css

ul li a {padding: 6px; border-bottom: 1px solid #666; background-image: none; color: #454545}

ul li a.selected { background: #fff url(triangle.png) no-repeat center bottom}

Tweak the background-position until it fits snuggly with the border.

查看更多
地球回转人心会变
4楼-- · 2019-06-02 18:01

I don't think there's a name for this, but it's going to be hard to make this in CSS without having to add a background image. With images it's fairly easy, see the other comments.

You could of course use :after with some CSS3 tricks to create an element simulating the arrow, like this:

http://jsfiddle.net/upeRE/2/

But it won't work in every browser and you'd have to know exactly how wide your menu items are.

查看更多
Evening l夕情丶
5楼-- · 2019-06-02 18:01

You need to look for css triangles menus (or css3 triangles). These are made with borders that are transparent. There is a good explanation of how you can make the triangles here:

http://jonrohan.me/guide/css/creating-triangles-in-css/

查看更多
三岁会撩人
6楼-- · 2019-06-02 18:06

I don't know how it is called, but I guess it does not correspond to any CSS property. You'll have to achieve this with background images I think.

查看更多
登录 后发表回答