실전퍼블리싱(풀스크린 탭 콘텐츠 슬라이더 프로토타입)

Dev_Go·2022년 7월 18일
0
post-thumbnail

풀스크린 탭 콘텐츠 슬라이더 프로토타입


예제보기

HTML

  <div class="tab-inner">
    <input type="radio" name="tabmenu" id="tab1" checked>
    <input type="radio" name="tabmenu" id="tab2">
    <input type="radio" name="tabmenu" id="tab3">
    <div class="tabs">
      <div class="items">
        <div>
          <h1>slide content 01</h1>
        </div>
        <div>
          <h1>slide content 02</h1>
        </div>
        <div>
          <h1>slide content 03</h1>
        </div>
      </div>
    </div>
    <div class="btn">
      <label for="tab1"></label>
      <label for="tab2"></label>
      <label for="tab3"></label>
    </div>
  </div>/* Google Web Font */
@import url('https://fonts.googleapis.com/css?family=Raleway&display=swap');

/* Fontawesome 4.7 */
@import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');

body {
  font-family: 'Raleway', sans-serif;
  line-height: 1.5em;
  margin: 0;
  font-weight: 300;
  color: #222;
}
a {
  text-decoration: none;
}

input[name=tabmenu] {
  display: none;
}
.tabs {
  overflow: hidden;
  position: relative;
  height: 100vh;
}
.items {
  height: 100vh;
  width: 300%;
  position: absolute;
  top: 0;
  left: 0;
  transition: 0.5s;
}
.items div {
  height: 100vh;
  float: left;
  width: 33.333333%;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
}
.items div:nth-child(1) {
  background-color: teal;
}
.items div:nth-child(2) {
  background-color: dodgerblue;
}
.items div:nth-child(3) {
  background-color: yellowgreen;
}
.items div h1 {
  font-size: 80px;
  font-weight: normal;
}
.btn {
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
}
.btn label{
  display: inline-block;
  height: 5px;
  width: 50px;
  background-color: #fff;
  cursor: pointer;
}

input[id=tab1]:checked ~ .tabs .items {
  left: 0;
}
input[id=tab2]:checked ~ .tabs .items {
  left: -100%;
}
input[id=tab3]:checked ~ .tabs .items {
  left: -200%;
}

input[id=tab1]:checked ~ .btn label[for=tab1],
input[id=tab2]:checked ~ .btn label[for=tab2],
input[id=tab3]:checked ~ .btn label[for=tab3] {
  background-color: #000;
}

CSS

/* Google Web Font */
@import url('https://fonts.googleapis.com/css?family=Raleway&display=swap');

/* Fontawesome 4.7 */
@import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');

body {
  font-family: 'Raleway', sans-serif;
  line-height: 1.5em;
  margin: 0;
  font-weight: 300;
  color: #222;
}
a {
  text-decoration: none;
}

input[name=tabmenu] {
  display: none;
}
.tabs {
  overflow: hidden;
  position: relative;
  height: 100vh;
}
.items {
  height: 100vh;
  width: 300%;
  position: absolute;
  top: 0;
  left: 0;
  transition: 0.5s;
}
.items div {
  height: 100vh;
  float: left;
  width: 33.333333%;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
}
.items div:nth-child(1) {
  background-color: teal;
}
.items div:nth-child(2) {
  background-color: dodgerblue;
}
.items div:nth-child(3) {
  background-color: yellowgreen;
}
.items div h1 {
  font-size: 80px;
  font-weight: normal;
}
.btn {
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
}
.btn label{
  display: inline-block;
  height: 5px;
  width: 50px;
  background-color: #fff;
  cursor: pointer;
}

input[id=tab1]:checked ~ .tabs .items {
  left: 0;
}
input[id=tab2]:checked ~ .tabs .items {
  left: -100%;
}
input[id=tab3]:checked ~ .tabs .items {
  left: -200%;
}

input[id=tab1]:checked ~ .btn label[for=tab1],
input[id=tab2]:checked ~ .btn label[for=tab2],
input[id=tab3]:checked ~ .btn label[for=tab3] {
  background-color: #000;
}
profile
프론트엔드 4년차

0개의 댓글