CSS3 Tab animation example background switching dynamic effect

CSS3 Tab animation example background switching dynamic effect

CSS 3 animation example - dynamic effect of Tab background switching, the specific code is as follows:

<style type="text/css">
.slide-tabs { display:flex; position:relative; border:1px solid #3d3d3d; border-radius:10px; width:150px; overflow:hidden; background:#1c1c1c; }
.slide-tabs * { z-index: 2; }
.slide-tabs input[type=radio] { display:none; }
.slide-tabs .tab { display:flex; align-items:center; justify-content:center; border-radius:9px; height:18px; font-size:12px; color:#fff; cursor:pointer; }
.slide-tabs .glider { display:flex; position:absolute; border-radius:9px; height:18px; background:#3da35a; z-index:1; transition:0.25s ease-out; } /*lower z-index */

.slide-tabs input[type=radio]:checked + label { color:#fff; } /*Modify the current item color as needed*/
.slide-tabs input[type=radio]:nth-of-type(1):checked ~ .glider { transform:translateX(0%); }
.slide-tabs input[type=radio]:nth-of-type(2):checked ~ .glider { transform:translateX(100%); }
.slide-tabs input[type=radio]:nth-of-type(3):checked ~ .glider { transform:translateX(200%); }

.slide-tabs.tabs-3x .tab,
.slide-tabs.tabs-3x .glider { width:50px; }
</style>

<div class="slide-tabs tabs-3x">
    <input type="radio" id="radio-1" value="1" name="tabs" checked="checked">
    <label class="tab" for="radio-1">Daily</label>
    <input type="radio" id="radio-2" value="2" name="tabs">
    <label class="tab" for="radio-2">Week</label>
    <input type="radio" id="radio-3" value="3" name="tabs">
    <label class="tab" for="radio-3">Month</label>
    <span class="glider"></span>
</div>

The code is as above. When you click "Day, Week, Month", in addition to selecting the current item, the green block below will also move. As shown below:

Clever

Using radio, this eliminates the need for JavaScript to set the current item.

At the same time, the radio is hidden, and the for attribute of the label associates the label with the radio. Clicking the label is equivalent to clicking the radio.

Clever 2

The transition is combined with transform:translateX, where translateX refers to the displacement in the x direction.

This concludes this article about the background switching dynamic effects of CSS3 Tab animation examples. For more related CSS3 tab background switching effects content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  Introduction to the use and advantages and disadvantages of MySQL triggers

>>:  The meaning of status code in HTTP protocol

Recommend

WeChat applet records user movement trajectory

Table of contents Add Configuration json configur...

Solution to find all child rows for a given parent row in MySQL

Preface Note: The test database version is MySQL ...

Specific use of MySQL operators (and, or, in, not)

Table of contents 1. Introduction 2. Main text 2....

Detailed explanation of HTML table inline format

Inline format <colgroup>...</colgroup>...

Use Vue3 for data binding and display list data

Table of contents 1. Comparison with Vue2 1. New ...

A brief discussion on the implementation principle of Vue slot

Table of contents 1. Sample code 2. See the essen...

Detailed explanation of the four transaction isolation levels in MySQL

The test environment of this experiment: Windows ...

How to connect to MySQL using C++

C++ connects to MySQL for your reference. The spe...

A brief understanding of the three principles of adding MySQL indexes

1. The Importance of Indexes Indexes are used to ...

In-depth explanation of MySQL learning engine, explain and permissions

engine Introduction Innodb engine The Innodb engi...

Nginx uses reverse proxy to implement load balancing process analysis

Introduction Based on docker container and docker...

Detailed explanation of Linux redirection usage

I believe that everyone needs to copy and paste d...

Examples of using MySQL pessimistic locking and optimistic locking

Pessimistic Lock Pessimistic lock, considers the ...

How to get USB scanner data using js

This article shares the specific process of js ob...