<input type="radio" name="name" checked="checked"/>
<div class="cp_item"><div class="inner">First Tab</div></div>
<input type="radio" name="name"/>
<div class="cp_item"><div class="inner">Second Tab</div></div>
<input type="radio" name="name"/>
<div class="cp_item"><div class="inner">Third Tab</div></div>
<input type="radio" name="name"/>
<div class="cp_item"><div class="inner">Force Tab</div></div>
html, body {
height: 100%;
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
}
.cp_item .inner {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
line-height: 1.2;
color: #fff;
z-index: 2;
}
.cp_item {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
-webkit-transition: -webkit-transform 0.4s ease;
transition: -webkit-transform 0.4s ease;
transition: transform 0.4s ease;
transition: transform 0.4s ease, -webkit-transform 0.4s ease;
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
.cp_item:nth-of-type(1) {
background-color: #F06292;
}
.cp_item:nth-of-type(2) {
background-color: #FFB74D;
}
.cp_item:nth-of-type(3) {
background-color: #81C784;
}
.cp_item:nth-of-type(4) {
background-color: #26C6DA;
}
input[type="radio"] {
position: absolute;
left: 0;
width: 2em;
height: 25%;
outline: 2em solid;
outline-offset: -2em;
margin: 0;
z-index: 1;
cursor: pointer;
}
input[type="radio"]:nth-of-type(1) {
outline-color: #F06292;
top: 0%;
}
input[type="radio"]:nth-of-type(2) {
outline-color: #FFB74D;
top: 25%;
}
input[type="radio"]:nth-of-type(3) {
outline-color: #81C784;
top: 50%;
}
input[type="radio"]:nth-of-type(4) {
outline-color: #26C6DA;
top: 75%;
}
input[type="radio"]:checked + .cp_item {
-webkit-transform: translateX(0%);
transform: translateX(0%);
-webkit-transition: -webkit-transform 0.4s ease 0.4s;
transition: -webkit-transform 0.4s ease 0.4s;
transition: transform 0.4s ease 0.4s;
transition: transform 0.4s ease 0.4s, -webkit-transform 0.4s ease 0.4s;
}
<div id="tab0"><div class="inner">First Tab</div></div>
<div id="tab1"><div class="inner">Second Tab</div></div>
<div id="tab2"><div class="inner">Third Tab</div></div>
<div id="tab3"><div class="inner">Force Tab</div></div>
<div id="tab4"><div class="inner">Fifth Tab</div></div>
html,body {
margin: 0;
}
.tab, #tab0, #tab1, #tab2, #tab3, #tab4 {
height: 100%;
position: absolute;
box-shadow: 6px 0px 3px rgba(0, 0, 0, 0.1);
transition: all 0.5s ease;
}
.tab:hover ~ div, #tab0:hover ~ div, #tab1:hover ~ div, #tab2:hover ~ div, #tab3:hover ~ div, #tab4:hover ~ div {
transform: translateX(-92vw);
}
#tab0 {
width: 100vw;
background: #E6EE9C;
}
#tab1,#tab2,#tab3,#tab4 {
width: 95vw;
}
#tab1 {
background: #C5E1A5;
}
#tab2 {
background: #A5D6A7;
}
#tab3 {
background: #80CBC4;
}
#tab4 {
background: #80DEEA;
}
#tab1::after, #tab2::after, #tab3::after, #tab4::after {
content: '';
position: absolute;
width: 4vw;
height: 15vh;
border-radius: 0 20px 20px 0;
right: -4vw;
}
#tab1::after {
background: #C5E1A5;
top: 45%;
}
#tab2::after {
background: #A5D6A7;
top: 30%;
}
#tab3::after {
background: #80CBC4;
top: 15%;
}
#tab4::after {
background: #80DEEA;
top: 0;
}
.inner {
position: absolute;
top: 25%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
line-height: 1.2;
color: #fff;
}
<div class="cp_fulltab03">
<div class="tabs_menu">
<input checked id="rad1" name="rad" type="radio">
<label data-text="First" for="rad1"></label>
<input id="rad2" name="rad" type="radio">
<label data-text="Second" for="rad2"></label>
<input id="rad3" name="rad" type="radio">
<label data-text="Third" for="rad3"></label>
<input id="rad4" name="rad" type="radio">
<label data-text="Force" for="rad4"></label>
<div class="tabs_cont">
<div class="card">
<h1>First Tab</h1>
<p><div class="css-script-ads">First Tab</div></p>
</div>
</div>
<div class="tabs_cont">
<div class="card">
<h1>Second Tab</h1>
<p><div class="css-script-ads">Second Tab</div></p>
</div>
</div>
<div class="tabs_cont">
<div class="card">
<h1>Third Tab</h1>
<p><div class="css-script-ads">Third Tab</div></p>
<p style="padding:30em 0;">Third Tab padding-top,bottom:30em</p>
</div>
</div>
<div class="tabs_cont">
<div class="card">
<h1>Force Tab</h1>
<p><div class="css-script-ads">Force Tab</div></p>
</div>
</div>
</div>
</div>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
.cp_fulltab03 {
position: relative;
float: left;
display: inline-block;
width: 100%;
height: 100%;
background: #37474F;
overflow: hidden;
}
.tabs_menu {
float: left;
display: inline-block;
width: 4rem;
height: 100%;
}
.tabs_menu, .tabs_menu * {
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
}
.tabs_menu > input[type='radio'] {
-webkit-appearance: none;
appearance: none;
display: none;
}
.tabs_menu > input[type='radio']:checked + label {
background: white;
}
.tabs_menu > input[type='radio']:checked + label:before {
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -50%, 0);
-webkit-transition: -webkit-transform 0.35s;
transition: transform 0.35s;
}
.tabs_menu > input[type='radio']:checked + label:after {
color: #37474F;
}
.tabs_menu > label {
border: none;
padding: 0;
background: none;
outline: none;
border-radius: 0;
-webkit-transition: background-position 0.25s, box-shadow 0.25s;
transition: background-position 0.25s, box-shadow 0.25s;
position: relative;
float: left;
display: inline-block;
width: 100%;
height: 25%;
text-align: center;
line-height: 25vh;
margin: 0;
background: #FF4081;
box-shadow: inset 0px 1px 0 white, inset -1px 0 0px 0px white;
}
.tabs_menu > label:first-of-type {
box-shadow: inset -1px 0 0px 0px white;
}
.tabs_menu > label:after {
content: attr(data-text);
position: absolute;
top: 50%;
left: 50%;
display: inline-block;
width: 100%;
color: white;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
-webkit-transition: color 0.25s;
transition: color 0.25s;
}
.tabs_menu > label:before {
content: '';
position: absolute;
left: 100%;
top: 50%;
display: inline-block;
width: 0;
height: 0;
border-style: solid;
border-width: 1rem;
border-color: transparent transparent transparent #ffffff;
-webkit-transform: translate(-5.5rem, -50%);
transform: translate(-5.5rem, -50%);
-webkit-transform: translate3d(-5.5rem, -50%, 0);
transform: translate3d(-5.5rem, -50%, 0);
-webkit-transition: -webkit-transform 0.2s;
transition: transform 0.2s;
}
.tabs_menu > .tabs_cont {
position: absolute;
display: inline-block;
width: 100%;
height: 90%;
left: 4rem;
text-align: center;
-webkit-transition: -webkit-transform 0.5s;
transition: transform 0.5s;
}
.tabs_menu > .tabs_cont > .card {
position: absolute;
left: 50%;
top: 50%;
display: inline-block;
width: 70%;
max-height: 50%;
overflow-x: hidden;
overflow-y: auto;
padding: 2rem;
box-shadow: 0 0 0 1px white;
color: white;
-webkit-overflow-scrolling: touch;
-webkit-transform: translate(-50%, -50%) translate(-1.5rem, 0);
transform: translate(-50%, -50%) translate(-1.5rem, 0);
-webkit-transform: translate3d(-50%, -50%, 0) translate3d(-1.5rem, 0, 0);
transform: translate3d(-50%, -50%, 0) translate3d(-1.5rem, 0, 0);
}
.tabs_menu > .tabs_cont > .card > h1 {
margin-top: 0;
}
.tabs_menu > input[type='radio']:nth-of-type(1):checked ~ .tabs_cont:nth-of-type(1) {
-webkit-transform: translate(0, 0%);
transform: translate(0, 0%);
-webkit-transform: translate3d(0, 0%, 0);
transform: translate3d(0, 0%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(1):checked ~ .tabs_cont:nth-of-type(2) {
-webkit-transform: translate(0, 100%);
transform: translate(0, 100%);
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(1):checked ~ .tabs_cont:nth-of-type(3) {
-webkit-transform: translate(0, 200%);
transform: translate(0, 200%);
-webkit-transform: translate3d(0, 200%, 0);
transform: translate3d(0, 200%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(1):checked ~ .tabs_cont:nth-of-type(4) {
-webkit-transform: translate(0, 300%);
transform: translate(0, 300%);
-webkit-transform: translate3d(0, 300%, 0);
transform: translate3d(0, 300%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(2):checked ~ .tabs_cont:nth-of-type(1) {
-webkit-transform: translate(0, -100%);
transform: translate(0, -100%);
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(2):checked ~ .tabs_cont:nth-of-type(2) {
-webkit-transform: translate(0, 0%);
transform: translate(0, 0%);
-webkit-transform: translate3d(0, 0%, 0);
transform: translate3d(0, 0%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(2):checked ~ .tabs_cont:nth-of-type(3) {
-webkit-transform: translate(0, 100%);
transform: translate(0, 100%);
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(2):checked ~ .tabs_cont:nth-of-type(4) {
-webkit-transform: translate(0, 200%);
transform: translate(0, 200%);
-webkit-transform: translate3d(0, 200%, 0);
transform: translate3d(0, 200%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(3):checked ~ .tabs_cont:nth-of-type(1) {
-webkit-transform: translate(0, -200%);
transform: translate(0, -200%);
-webkit-transform: translate3d(0, -200%, 0);
transform: translate3d(0, -200%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(3):checked ~ .tabs_cont:nth-of-type(2) {
-webkit-transform: translate(0, -100%);
transform: translate(0, -100%);
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(3):checked ~ .tabs_cont:nth-of-type(3) {
-webkit-transform: translate(0, 0%);
transform: translate(0, 0%);
-webkit-transform: translate3d(0, 0%, 0);
transform: translate3d(0, 0%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(3):checked ~ .tabs_cont:nth-of-type(4) {
-webkit-transform: translate(0, 100%);
transform: translate(0, 100%);
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(4):checked ~ .tabs_cont:nth-of-type(1) {
-webkit-transform: translate(0, -300%);
transform: translate(0, -300%);
-webkit-transform: translate3d(0, -300%, 0);
transform: translate3d(0, -300%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(4):checked ~ .tabs_cont:nth-of-type(2) {
-webkit-transform: translate(0, -200%);
transform: translate(0, -200%);
-webkit-transform: translate3d(0, -200%, 0);
transform: translate3d(0, -200%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(4):checked ~ .tabs_cont:nth-of-type(3) {
-webkit-transform: translate(0, -100%);
transform: translate(0, -100%);
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
.tabs_menu > input[type='radio']:nth-of-type(4):checked ~ .tabs_cont:nth-of-type(4) {
-webkit-transform: translate(0, 0%);
transform: translate(0, 0%);
-webkit-transform: translate3d(0, 0%, 0);
transform: translate3d(0, 0%, 0);
}
コピペでできる!CSSとhtmlだけのシンプルなタブ切り替え2種 | copypet.jp|パーツで探す、web制作に使えるコピペサイト。
ページ内の情報を整理する時などによく使うタブ切り替え。 CSSとHTMLだけで作るシンプルなタブ切り替えを用意しました。 横並びのタブと縦並びのタブです。 カスタマイズのベースとしてお使いいただければと思います。…コピペでできる!CSSとhtmlだけの切り替えエフェクトがグッとくるタブ切り替え5種 | copypet.jp|パーツで探す、web制作に使えるコピペサイト。
ページ内の情報を整理する時などによく使うタブ切り替え。 CSSとHTMLだけで作る切り替えエフェクトがグッとくるタブ切り替えを用意しました。…