css Tabs 纯css滑块

#   css Tabs 纯css滑块



<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
}

html {
  font-size: 62.5%;
  box-sizing: border-box;
}

body {
  font-family: "Mulish", sans-serif;
  color: #fff;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background-color: #0f172a;
}

.widget {
  background: #17181a;
  width: 360px;
  border: 1px solid #222f43;
  border-radius: 20px;
  background-color: #131c31;
  color: #b9e0f2;
  box-shadow: 0 10px 10px 0 rgba(0, 0, 0, 0.05);
}

input {
  display: none;
}

.buttons {
  position: relative;
  display: flex;
  border-bottom: 1px solid #222f43;
}
.buttons label {
  padding: 20px 10px;
  font-size: 1.7rem;
  width: 80px;
  text-align: center;
  opacity: 0.35;
  cursor: pointer;
}
.buttons .underline {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 80px;
  height: 3px;
  background: #0ea5ea;
  transition: 0.2s;
}

.content {
  position: relative;
  overflow: hidden;
  height: 140px;
}
.content .content-inner {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  width: 1080px;
  transition: 0.3s;
}
.content .content-inner > div {
  width: inherit;
  padding: 20px;
}
.content .content-inner h2 {
  margin: 0 0 10px;
  font-size: 2rem;
  font-weight: 400;
}
.content .content-inner p {
  margin: 0;
  font-size: 1.6rem;
}

.tabs input:nth-child(1):checked ~ .buttons .underline {
  translate: 0 0;
}
.tabs input:nth-child(2):checked ~ .buttons .underline {
  translate: 80px 0;
}
.tabs input:nth-child(3):checked ~ .buttons .underline {
  translate: 160px 0;
}
.tabs input:nth-child(1):checked ~ .buttons label:nth-child(1),
.tabs input:nth-child(2):checked ~ .buttons label:nth-child(2),
.tabs input:nth-child(3):checked ~ .buttons label:nth-child(3) {
  opacity: 1;
}
.tabs input:nth-child(1):checked ~ .content > .content-inner {
  translate: 0 0;
}
.tabs input:nth-child(2):checked ~ .content > .content-inner {
  translate: -360px 0;
}
.tabs input:nth-child(3):checked ~ .content > .content-inner {
  translate: -720px 0;
}
</style>
<div class="widget">
  <div class="tabs">
    <input type="radio" name="group" id="tab-1" checked>
    <input type="radio" name="group" id="tab-2">
    <input type="radio" name="group" id="tab-3">

    <div class="buttons">
      <label for="tab-1">Apps</label>
      <label for="tab-2">Battery</label>
      <label for="tab-3">Storage</label>
      <div class="underline"></div>
    </div>

    <div class="content">
      <div class="content-inner">
        <div>
          <h2>Apps</h2>
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</p>
        </div>

        <div>
          <h2>Battery</h2>
          <p>At vero eos et accusam et justo duo dolores et ea rebum.</p>
        </div>

        <div>
          <h2>Storage</h2>
          <p> At vero eos et accusam et justo duo dolores et ea rebum</p>
        </div>
      </div>
    </div>

  </div>
</div>


# xiaoxiao [ 2023-09-17 ]

# Address in this article

# http://www.s7smile.com/html/50

# s7smile.com