Jump to content

Recommended Posts

I'm interested in using something like this code on my site to create dynamic page-width tabs, wherein different content would display when each tab is selected. It would be like sections, however horizontal rather an infinite scroll down. https://codepen.io/tari/pen/mVdLXy?editors=1111

 

Is it possible to inject as a code block? And then add images or additional code for that specific color group?

Link to comment
  • Replies 1
  • Views 590
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Add a Code Block > Paste this code


<div class="tabs">
  <input type="radio" name="name" checked="checked"/>
  <div class="content">
    <div class="title">Pure CSS Color Tabs</div>
  </div>
  <input type="radio" name="name"/>
  <div class="content">
    <div class="title">Pure CSS Color Tabs 2</div>
  </div>
  <input type="radio" name="name"/>
  <div class="content">
    <div class="title">Pure CSS Color Tabs 3</div>
  </div>
  <input type="radio" name="name"/>
  <div class="content">
    <div class="title">Pure CSS Color Tabs 4</div>
  </div>
</div>
<style>
  .tabs {
  height: 100vh;
  position: relative;
  overflow: hidden;
}

input[type=radio] {
  position: absolute;
  left: 0;
  width: 24px;
  height: 25%;
  outline: 12px solid;
  outline-offset: -12px;
  margin: 0;
  padding: 0;
  z-index: 1;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  cursor: pointer;
}
input[type=radio]:nth-of-type(1) {
  outline-color: #f06868;
  top: 0%;
}
input[type=radio]:nth-of-type(2) {
  outline-color: #fab57a;
  top: 25%;
}
input[type=radio]:nth-of-type(3) {
  outline-color: #edf798;
  top: 50%;
}
input[type=radio]:nth-of-type(4) {
  outline-color: #80d6ff;
  top: 75%;
}
input[type=radio]:checked + .content {
  transform: translateX(0%);
  transition: transform 0.4s ease 0.4s;
}

.content {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-flow: column;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.4s ease;
  transform: translateX(-100%);
}
.content:nth-of-type(1) {
  background-color: #f06868;
}
.content:nth-of-type(2) {
  background-color: #fab57a;
}
.content:nth-of-type(3) {
  background-color: #edf798;
}
.content:nth-of-type(4) {
  background-color: #80d6ff;
}

.title {
  font-size: 5vw;
  font-weight: bold;
  color: #fff;
}
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.