JSFiddle - React, Tailwind, and code Playground
by copyhold
HTML
<main>
<h2 class="active tab">заголовок 1</h2>
<div class=tab>telo 1</div>
<h2 class=tab>заголовок 2</h2>
<div class=tab>telo 2</div>
<h2 class=tab>заголовок 3</h2>
<div class=tab>telo 3</div>
<hr>
</main>
SCSS
main {
weight: 800px;
}
h2.tab {
margin: 0;
cursor: pointer;
display: block;
float: left;
position: relative;
height: 60px;
line-height: 60px;
color: $bgblue;
padding: 0 10px;
cursor: pointer;
border-top: 5px solid transparent;
font-size: 1.1em;
text-align: center;
font-weight: bold;
background: #ebebeb;
&.active {
cursor: default;
background: #fff;
border-top: 5px solid yellow;
font-weight: bold;
color: $gray;
&:after { display: none; }
}
&:after {
content:" ";
height: 48px;
border-left:1px solid #ccc;
border-right: 1px solid #fff;
width:0;
overflow:hidden;
position: absolute;
right: 0;
top:5px;
}
}
div.tab {
margin-top: 65px;
float: right;
width: 100%;
margin-left: -100%;
display: none;
}
h2.tab.active+div.tab {
display: block;
}
hr {
clear: both;
}
}
JavaScript
$('h2.tab').click(function(){
if ($(this).hasClass('active')) return;
$(this).addClass('active').siblings('h2').removeClass('active');
});