실전퍼블리싱(풀스크린 탭 콘텐츠 슬라이더 응용)

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">Graphic</label>
      <label for="tab2">Web Publishing</label>
      <label for="tab3">Logo & CI</label>
    </div>
  </div>

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;
  color: #fff;
  position: relative;

}
.items div:nth-child(1) {
  background: url('../images/photo-01.jpg') no-repeat center center;
  background-size: cover;
  background-attachment: fixed;
}
.items div:nth-child(2) {
  background: url('../images/photo-02.jpg') no-repeat center center fixed;
  background-size: cover;
}
.items div:nth-child(3) {
  background: url('../images/photo-03.jpg') no-repeat center center fixed;
  background-size: cover;
}
.items div::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
}
.items div:nth-child(1)::before {
  background: linear-gradient(135deg, gold, transparent);
}
.items div:nth-child(2)::before {
  background: linear-gradient(135deg, crimson, transparent);
}
.items div:nth-child(3)::before {
  background: linear-gradient(135deg, royalblue, transparent);
}
.items div h1 {
  font-size: 80px;
  font-weight: normal;
  position: relative;
  font-size: 150px;
  line-height: 150px;
  text-align: center;
  transform: translateY(-200px);
  opacity: 0;
  transition: 0.5s;
  transition-delay: 0.5s;
}
.btn {
  position: absolute;
  bottom: 20px;
  width: 100%;
  height: 40px;
  line-height: 40px;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.4);
  bottom: 0;
}
.btn label{
  display: inline-block;
  cursor: pointer;
  color: #fff;
  margin: 0 15px;
}

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] {
  color: #000;
  font-weight: bold;
}
input[id=tab1]:checked ~ .tabs .items div:nth-child(1) h1,
input[id=tab2]:checked ~ .tabs .items div:nth-child(2) h1,
input[id=tab3]:checked ~ .tabs .items div:nth-child(3) h1 {
  transform: translateY(200px);
  opacity: 1;
}
profile
프론트엔드 4년차

0개의 댓글