Pure CSS for breadcrumb-style navigation

Source: Internet
Author: User

A breadcrumb-style navigation was made with reference to the tutorial. Here to share the implementation of the way, you are also reviewing. First effect

The HTML code is as follows:

<div id= "crumbs" ><ul><li><a href= "#" >breadcrumb</a></li></ul></div >

We use an unordered list to populate breadcrumb navigation. Each navigation connection is equivalent to a <li> element with a <a> element embedded in it.
Each of the A elements is first rendered as a blue rectangular box. Center the text in place with the appropriate padding on both sides. Settings <a> elements are relative positioning. This allows its absolute positioning of the child elements to be positioned relative to it.
#crumbs ul Li a {display:block;float:left;height:50px;background: #3498db; text-align:center;padding:30px 40px 0 40px; position:relative;margin:0 10px 0 0; Font-size:20px;text-decoration:none;color: #fff;}

Use the: After selector to create an element. Use CSS borders to create a triangle. To use: The elements generated by the after selector apply the upper and lower borders, the left border, and then set the color of the upper and lower borders to transparent. When placing the element in the appropriate place (via Position:absolute), note the setting Z-index

#crumbs ul Li a:after {content: "";  border-top:40px Solid red;border-bottom:40px solid red;border-left:40px solid blue;position:absolute; Right: -40px; top:0;
Z-index:5;}

Set the upper and lower borders to transparent, and then reset the color of the left border
border-top:40px Solid transparent;border-bottom:40px solid transparent;border-left:40px solid #3498db;

Using the same method, a triangular style is rendered on the left side of the rectangle box. This time or set: the top and bottom border of the before element is transparent, the color of the left box is set to match the background color of the page, disguised as part of the page
#crumbs ul Li A:before {content: "";  border-top:40px Solid transparent;border-bottom:40px Solid transparent;border-left:40px solid #d4f2ff;p osition: Absolute left:0; top:0;}

<div id= "crumbs" ><ul><li><a href= "#1" >one</a></li><li><a href= "#2" >two</a></li><li><a href= "#3" >three</a></li><li><a href= "#4" > Four</a></li><li><a href= "#5" >Five</a></li></ul></div>

#crumbs ul Li:first-child a {border-top-left-radius:10px; border-bottom-left-radius:10px;} #crumbs ul li:first-child a:before {display:none;} #crumbs ul Li:last-child a {padding-right:80px;border-top-right-radius:10px; border-bottom-right-radius:10px;} #crumbs ul li:last-child a:after {display:none;}
#crumbs ul li a:hover {background: #fa5ba5;} #crumbs ul Li A:hover:after {border-left-color: #fa5ba5;}
This time a complete breadcrumbs navigation is complete. Translation level still needs to be improved ...
Attached original address: Http://line25.com/tutorials/how-to-create-flat-style-breadcrumb-links-with-css



Pure CSS for breadcrumb-style navigation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.