
<ul class="tabs group"> <li class="active"><a href="#one">One</a></li> <li><a href="#two">Two</a></li> <li><a href="#three">Three</a></li> <li><a href="#three">Four</a></li> </ul>
List items are usually a block element, and anchor is a lowercase element. So we get this kind of layaut.
Assigning float: left elements to the list, we line them up and shorten them to the width of the anchor inside. In fact - up to the width of the content.
The elements of the list themselves do not have indents or margins (margin or padding), so the elements of the list and anchors nested in them have the same size.
Let's take a closer look at one tab.
We use two of the four pseudo-elements to arrange the circles on the left and right of the bottom edge of the tab.
With the help of the remaining two pseudo-elements, we will create smaller rectangles.
The active tab and content have a general background color.
The rectangles correspond to the color of the active tab, the circles correspond to the color of the background behind them.
With the help of z-index we provide overlapping of rectangles with circles.
The frame was just an illustration, in fact, it will look somewhere like that.
We apply the same principle for external tabs and round the top corners with the help of border-radius. Is done. .tabs li { /* */ float: left; /* */ position: relative; } .tabs a { /* */ float: left; padding: 10px 40px; text-decoration: none; /* */ color: black; background: #ddc385; /* */ -webkit-border-top-left-radius: 15px; -webkit-border-top-right-radius: 15px; -moz-border-radius-topleft: 15px; -moz-border-radius-topright: 15px; border-top-left-radius: 15px; border-top-right-radius: 15px; } .tabs .active { /* */ z-index: 3; } .tabs .active a { /* */ background: white; color: black; } .tabs li:before, .tabs li:after, .tabs li a:before, .tabs li a:after { /* */ position: absolute; bottom: 0; } /* , , */ .tabs li:last-child:after, .tabs li:last-child a:after, .tabs li:first-child:before, .tabs li:first-child a:before, .tabs .active:after, .tabs .active:before, .tabs .active a:after, .tabs .active a:before { content: ""; } .tabs .active:before, .tabs .active:after { background: white; /* */ z-index: 1; } /* */ .tabs li:before, .tabs li:after { background: #ddc385; width: 10px; height: 10px; } .tabs li:before { left: -10px; } .tabs li:after { right: -10px; } /* */ .tabs li a:after, .tabs li a:before { width: 20px; height: 20px; /* … … */ -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; background: #222; /* */ z-index: 2; } .tabs .active a:after, .tabs .active a:before { background: #ddc385; } /* */ .tabs li:first-child.active a:before, .tabs li:last-child.active a:after { background: #222; } .tabs li a:before { left: -20px; } .tabs li a:after { right: -20px; } <style> /* */ /*ie 7*/ *+html .tabs li{ background: url("img/tabs.png") 0 -37px no-repeat; } *+html .tabs li a{ background: url("img/tabs.png") 100% -37px no-repeat; padding: 10px 40px 10px 20px; margin:0 0 0 20px; } *+html .tabs li.active{ background:url("img/tabs.png") 0 0 no-repeat; } *+html .tabs li.active a{ background:url("img/tabs.png") 100% 0 no-repeat; } *+html .tabs li{ zoom:expression(function(t) { t.runtimeStyle.zoom = 1; var before = document.createElement('span'); var after = document.createElement('span'); before.className = 'before-fix-for-ie'; after.className = 'after-fix-for-ie'; t.appendChild(before); t.appendChild(after); }(this)); } /*ie 6*/ * html .tabs li{ background:url("img/tabs.png") 0 -37px no-repeat; } * html .tabs li a{ background:url("img/tabs.png") 100% -37px no-repeat; padding: 10px 40px 10px 20px; margin:0 0 0 20px; } * html .tabs li.active{ background-position:0 0; } * html .tabs li.active a{ background:url("img/tabs.png") 100% 0 no-repeat; } * html .tabs li{ zoom:expression(function(t) { t.runtimeStyle.zoom = 1; var before = document.createElement('span'); var after = document.createElement('span'); before.className = 'before-fix-for-ie'; after.className = 'after-fix-for-ie'; t.appendChild(before); t.appendChild(after); }(this)); } /* */ .tabs li .before-fix-for-ie{ position:absolute; overflow:hidden; font-size:0; line-height:0; top:27px; left:-10px; width:10px; height:10px; background:url("img/left.png") 0 0 no-repeat; } * html .tabs li .before-fix-for-ie{ background:none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='img/left.png', sizingMethod='image'); } .tabs li.active .before-fix-for-ie{ background:url("img/active-left.png") 0 0 no-repeat; } * html .tabs li.active .before-fix-for-ie{ background:none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='img/active-left.png', sizingMethod='image'); } .after-fix-for-ie{ position:absolute; overflow:hidden; font-size:0; line-height:0; top:27px; right:-10px; width:10px; height:10px; background:url("img/right.png") 0 0 no-repeat; } * html .tabs li .after-fix-for-ie{ background:none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='img/right.png', sizingMethod='image'); } .tabs li.active .after-fix-for-ie{ background:url("img/active-right.png") 0 0 no-repeat; } * html .tabs li.active .after-fix-for-ie{ background:none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='img/active-right.png', sizingMethod='image'); } </style> <!--[if IE 8]> <style> /*ie 8*/ .tabs li{ background:transparent url("img/tabs.png") 0 -37px no-repeat; } .tabs li a{ background:transparent url("img/tabs.png") 100% -37px no-repeat; padding: 10px 40px 10px 20px; margin:0 0 0 20px; } .tabs li.active{ background:transparent url("img/tabs.png") 0 0 no-repeat; } .tabs li.active a{ background:transparent url("img/tabs.png") 100% 0 no-repeat; } body .tabs li:before{ content:"."; text-indent:-9000px; overflow:hidden; height:10px; width:10px; font-size:0; line-height:0; display:block; position:absolute; top:27px; left:-10px; z-index:10; zoom:1; background:transparent url("img/left.png") 0 0 no-repeat; } body .tabs li:after{ content:"."; text-indent:-9000px; overflow:hidden; height:10px; width:10px; font-size:0; line-height:0; display:block; position:absolute; top:27px; right:-10px; z-index:10; zoom:1; background:transparent url("img/right.png") 0 0 no-repeat; } body .tabs li.active:before{ content:"."; text-indent:-9000px; overflow:hidden; height:10px; width:10px; font-size:0; line-height:0; display:block; position:absolute; top:27px; left:-10px; z-index:10; zoom:1; background:transparent url("img/active-left.png") 0 0 no-repeat; } body .tabs li.active:after{ content:"."; text-indent:-9000px; overflow:hidden; height:10px; width:10px; font-size:0; line-height:0; display:block; position:absolute; top:27px; right:-10px; z-index:10; zoom:1; background:transparent url("img/active-right.png") 0 0 no-repeat; } </style> <![endif]--> Source: https://habr.com/ru/post/128210/
All Articles