찾다
웹 프론트엔드CSS 튜토리얼심플하고 세련된 순수 CSS3 탭 탭 효과

간단한 튜토리얼

순수한 CSS3를 사용하여 만든 탭 탭 효과입니다. 탭 탭은 심플하고 스타일리시하며, 탭 간 전환 시 밑줄을 따르는 애니메이션이 사용되어 전체적인 효과가 매우 좋습니다.

HTML 구조

탭 탭 전체의 HTML 구조는 여러 부분으로 나누어져 있습니다. 탐색을 위해서는 요소와 순서가 지정되지 않은 목록을 사용하세요.

<input type="radio" id="tab1" name="tab-control" checked>
<input type="radio" id="tab2" name="tab-control">
<input type="radio" id="tab3" name="tab-control">  
<input type="radio" id="tab4" name="tab-control">
<ul>
  <li title="tab 1"><label for="tab1" role="button"><span>Tab 1</span></label></li>
  <li title="tab 2"><label for="tab2" role="button"><span>Tab 2</span></label></li>
  <li title="tab 3"><label for="tab3" role="button"><span>Tab 3</span></label></li>
  <li title="tab 4"><label for="tab4" role="button"><span>Tab 4</span></label></li>
</ul>

각 탭의 콘텐츠는

요소에 포함됩니다.

<p class="content">
  <section>
    <h2 id="Tab-nbsp-nbsp-content">Tab 1 content</h2>
  </section>
  <section>
    <h2 id="Tab-nbsp-nbsp-content">Tab 2 content</h2>
  </section>
  <section>
    <h2 id="Tab-nbsp-nbsp-content">Tab 3 content</h2>
  </section>
  <section>
    <h2 id="Tab-nbsp-nbsp-content">Tab 4 content</h2>
  </section>
</p>

밑줄에 애니메이션을 적용하는 데 사용되는 선은

요소를 사용하여 생성됩니다.

<p class="slider"><p class="indicator"></p></p>

CSS 스타일

Tabs 탭의 주요 CSS 스타일은 다음과 같습니다.

.tabs {
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  position: relative;
  background: white;
  padding: 50px;
  padding-bottom: 80px;
  width: 70%;
  height: 250px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  border-radius: 5px;
  min-width: 240px;
}
 
.tabs input[name="tab-control"] { display: none; }
 
.tabs .content section h2, .tabs ul li label {
  font-weight: bold;
  font-size: 18px;
  color: #428BFF;
}
 
.tabs ul {
  list-style-type: none;
  padding-left: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -webkit-flex-direction: row;
  -ms-flex-direction: row;
  flex-direction: row;
  margin-bottom: 10px;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  -ms-flex-pack: justify;
  justify-content: space-between;
  -webkit-box-align: end;
  -webkit-align-items: flex-end;
  -ms-flex-align: end;
  align-items: flex-end;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}
 
.tabs ul li {
  box-sizing: border-box;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -ms-flex: 1;
  flex: 1;
  width: 25%;
  padding: 0 10px;
  text-align: center;
}
 
.tabs ul li label {
  -webkit-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  color: #929daf;
  padding: 5px auto;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  cursor: pointer;
  -webkit-transition: all 0.2s ease-in-out;
  transition: all 0.2s ease-in-out;
  white-space: nowrap;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
 
.tabs ul li label br { display: none; }
 
.tabs ul li label svg {
  fill: #929daf;
  height: 1.2em;
  vertical-align: bottom;
  margin-right: 0.2em;
  -webkit-transition: all 0.2s ease-in-out;
  transition: all 0.2s ease-in-out;
}
 
.tabs ul li label:hover, .tabs ul li label:focus, .tabs ul li label:active {
  outline: 0;
  color: #bec5cf;
}
 
.tabs ul li label:hover svg, .tabs ul li label:focus svg, .tabs ul li label:active svg { fill: #bec5cf; }
 
.tabs .slider {
  position: relative;
  width: 25%;
  -webkit-transition: all 0.33s cubic-bezier(0.38, 0.8, 0.32, 1.07);
  transition: all 0.33s cubic-bezier(0.38, 0.8, 0.32, 1.07);
}
 
.tabs .slider .indicator {
  position: relative;
  width: 50px;
  max-width: 100%;
  margin: 0 auto;
  height: 4px;
  background: #428BFF;
  border-radius: 1px;
}
 
.tabs .content { margin-top: 30px; }
 
.tabs .content section {
  display: none;
  -webkit-animation-name: content;
  animation-name: content;
  -webkit-animation-direction: normal;
  animation-direction: normal;
  -webkit-animation-duration: 0.3s;
  animation-duration: 0.3s;
  -webkit-animation-timing-function: ease-in-out;
  animation-timing-function: ease-in-out;
  -webkit-animation-iteration-count: 1;
  animation-iteration-count: 1;
  line-height: 1.4;
}
 
.tabs .content section h2 {
  color: #428BFF;
  display: none;
}
 
.tabs .content section h2::after {
  content: "";
  position: relative;
  display: block;
  width: 30px;
  height: 3px;
  background: #428BFF;
  margin-top: 5px;
  left: 1px;
}
 
.tabs input[name="tab-control"]:nth-of-type(1):checked ~ ul > li:nth-child(1) > label {
  cursor: default;
  color: #428BFF;
}
 
.tabs input[name="tab-control"]:nth-of-type(1):checked ~ ul > li:nth-child(1) > label svg { fill: #428BFF; }
@media (max-width: 600px) {
 
.tabs input[name="tab-control"]:nth-of-type(1):checked ~ ul > li:nth-child(1) > label { background: rgba(0, 0, 0, 0.08); }
}
 
.tabs input[name="tab-control"]:nth-of-type(1):checked ~ .slider {
  -webkit-transform: translateX(0%);
  transform: translateX(0%);
}
 
.tabs input[name="tab-control"]:nth-of-type(1):checked ~ .content > section:nth-child(1) { display: block; }
 
.tabs input[name="tab-control"]:nth-of-type(2):checked ~ ul > li:nth-child(2) > label {
  cursor: default;
  color: #428BFF;
}
 
.tabs input[name="tab-control"]:nth-of-type(2):checked ~ ul > li:nth-child(2) > label svg { fill: #428BFF; }
@media (max-width: 600px) {
 
.tabs input[name="tab-control"]:nth-of-type(2):checked ~ ul > li:nth-child(2) > label { background: rgba(0, 0, 0, 0.08); }
}
 
.tabs input[name="tab-control"]:nth-of-type(2):checked ~ .slider {
  -webkit-transform: translateX(100%);
  transform: translateX(100%);
}
 
.tabs input[name="tab-control"]:nth-of-type(2):checked ~ .content > section:nth-child(2) { display: block; }
 
.tabs input[name="tab-control"]:nth-of-type(3):checked ~ ul > li:nth-child(3) > label {
  cursor: default;
  color: #428BFF;
}
 
.tabs input[name="tab-control"]:nth-of-type(3):checked ~ ul > li:nth-child(3) > label svg { fill: #428BFF; }
@media (max-width: 600px) {
 
.tabs input[name="tab-control"]:nth-of-type(3):checked ~ ul > li:nth-child(3) > label { background: rgba(0, 0, 0, 0.08); }
}
 
.tabs input[name="tab-control"]:nth-of-type(3):checked ~ .slider {
  -webkit-transform: translateX(200%);
  transform: translateX(200%);
}
 
.tabs input[name="tab-control"]:nth-of-type(3):checked ~ .content > section:nth-child(3) { display: block; }
 
.tabs input[name="tab-control"]:nth-of-type(4):checked ~ ul > li:nth-child(4) > label {
  cursor: default;
  color: #428BFF;
}
 
.tabs input[name="tab-control"]:nth-of-type(4):checked ~ ul > li:nth-child(4) > label svg { fill: #428BFF; }
@media (max-width: 600px) {
 
.tabs input[name="tab-control"]:nth-of-type(4):checked ~ ul > li:nth-child(4) > label { background: rgba(0, 0, 0, 0.08); }
}
 
.tabs input[name="tab-control"]:nth-of-type(4):checked ~ .slider {
  -webkit-transform: translateX(300%);
  transform: translateX(300%);
}
 
.tabs input[name="tab-control"]:nth-of-type(4):checked ~ .content > section:nth-child(4) { display: block; }
@-webkit-keyframes 
content {  from {
 opacity: 0;
 -webkit-transform: translateY(5%);
 transform: translateY(5%);
}
 
to {
  opacity: 1;
  -webkit-transform: translateY(0%);
  transform: translateY(0%);
}
}
@keyframes 
content {  from {
 opacity: 0;
 -webkit-transform: translateY(5%);
 transform: translateY(5%);
}
 
to {
  opacity: 1;
  -webkit-transform: translateY(0%);
  transform: translateY(0%);
}
}
@media (max-width: 1000px) {
 
.tabs ul li label { white-space: initial; }
 
.tabs ul li label br { display: initial; }
 
.tabs ul li label svg { height: 1.5em; }
}
@media (max-width: 600px) {
 
.tabs ul li label {
  padding: 5px;
  border-radius: 5px;
}
 
.tabs ul li label span { display: none; }
 
.tabs .slider { display: none; }
 
.tabs .content { margin-top: 20px; }
 
.tabs .content section h2 { display: block; }

위 내용은 심플하고 스타일리시한 순수 CSS3 Tabs 탭 효과의 내용이며, 더 많은 관련 내용 PHP 중국어 홈페이지(www.php.cn)를 주목해주세요!

관련 기사:

WeChat Mini 프로그램: 탭 효과 구현 예

WeChat Mini 프로그램에서 탭 효과 구현

javascript는 탭 전환 효과를 구현합니다

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
'Podcast 구독'링크는 어디에서 링크해야합니까?'Podcast 구독'링크는 어디에서 링크해야합니까?Apr 16, 2025 pm 12:04 PM

한동안 iTunes는 팟 캐스팅에서 큰 개 였으므로 "Podcast 구독"을 링크 한 경우 다음과 같습니다.

브라우저 엔진 다양성브라우저 엔진 다양성Apr 16, 2025 pm 12:02 PM

우리는 그들이 2013 년에 크롬에 갔을 때 오페라를 잃었습니다. 올해 초 크롬 (Chrome)에 갔을 때 Edge와 같은 거래를했습니다. Mike Taylor는 이러한 변화를 "감소 적으로"불렀습니다

웹 공유에 대한 UX 고려 사항웹 공유에 대한 UX 고려 사항Apr 16, 2025 am 11:59 AM

Trashy Clickbait 사이트에서 가장 8 월 출판물에 이르기까지 공유 버튼은 웹 전체에서 오랫동안 어디서 유비쿼터스되었습니다. 그럼에도 불구하고 이것들은 논쟁의 여지가 있습니다

Weekly Platform News : Apple은 웹 구성 요소, 프로그레시브 HTML 렌더링, 자체 호스팅 중요한 리소스를 배포합니다.Weekly Platform News : Apple은 웹 구성 요소, 프로그레시브 HTML 렌더링, 자체 호스팅 중요한 리소스를 배포합니다.Apr 16, 2025 am 11:55 AM

이번 주에 Apple은 웹 구성 요소, Instagram이 Insta-Loading 스크립트의 방법 및 자조적 자체 호스팅 리소스를 생각하기위한 음식을 웹 구성 요소에 들어갑니다.

Git Pathspecs 및 사용 방법Git Pathspecs 및 사용 방법Apr 16, 2025 am 11:53 AM

GIT 명령의 문서를 살펴 보았을 때 많은 사람들이 옵션이 있음을 알았습니다. 나는 처음에 이것이 단지 a라고 생각했다

제품 이미지를위한 컬러 피커제품 이미지를위한 컬러 피커Apr 16, 2025 am 11:49 AM

어려운 문제가 어려운 것 같지 않습니다. 우리는 종종 수천 가지 색상의 제품 샷을 가지고 있으므로 우리는 다음과 같이 뒤집을 수 있습니다. 우리도 아닙니다

Dark Mode는 React 및 Temprovider로 전환합니다Dark Mode는 React 및 Temprovider로 전환합니다Apr 16, 2025 am 11:46 AM

웹 사이트에 어두운 모드 옵션이있을 때 좋아합니다. 다크 모드는 웹 페이지를 더 쉽게 읽을 수있게하고 눈이 더 편안하다고 느끼도록 도와줍니다. 많은 웹 사이트를 포함합니다

HTML 대화 요소와 함께 일부 실습HTML 대화 요소와 함께 일부 실습Apr 16, 2025 am 11:33 AM

이것은 처음으로 HTML 요소를보고 있습니다. 나는 그것을 잠시 동안 알고 있었지만 아직 스핀을 위해 그것을 가져 갔다. 그것은 꽤 시원하고 있습니다

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 채팅 명령 및 사용 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구