css实现tab选项卡切换效果代码

代码语言:html

所属分类:选项卡

代码描述:css实现tab选项卡切换效果代码

代码标签: css tab 选项卡 切换

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
<style>
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 50px;
  display: grid;
  min-height: 100vh;
  place-items: center;
}

html {
  font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
  line-height: 1.5rem;
  font-size: 1.3em;
}

label {
  display: block;
}

.tabs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  grid-template-rows: auto 1fr;
  min-height: 400px;
}
.tabs label {
  display: contents;
}
.tabs label .tab {
  text-align: center;
  padding: 10px 20px;
  position: relative;
  grid-row: 1/span 1;
}
.tabs label .tab:focus-within {
  box-shadow: inset 0px -4px 0px goldenrod;
}
.tabs label .tab input {
  position: absolute;
  top: 0;
  height: 0;
  width: 0;
  opacity: 0;
}
.tabs label .tab:has(input:checked) {
  background: papayawhip;
}
.tabs label .tab-content {
  grid-row: 2/span 1;
  grid-column: 1/-1;
  display: none;
  padding: 20px;
}
.tabs label:has(input:checked) .tab-content {
  display: block;
  background-color: papayawhip;
}
</style>

  
  
</head>

<body translate="no">
  <h1>Pure CSS Tabs</h1>

<div class="tabs" role="tablist">
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0