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
Table of contents Add Configuration json configur...
Preface Note: The test database version is MySQL ...
Table of contents 1. Introduction 2. Main text 2....
Inline format <colgroup>...</colgroup>...
Table of contents 1. Comparison with Vue2 1. New ...
Table of contents 1. Sample code 2. See the essen...
The test environment of this experiment: Windows ...
C++ connects to MySQL for your reference. The spe...
1. The Importance of Indexes Indexes are used to ...
I spent almost two hours trying various methods. ...
engine Introduction Innodb engine The Innodb engi...
Introduction Based on docker container and docker...
I believe that everyone needs to copy and paste d...
Pessimistic Lock Pessimistic lock, considers the ...
This article shares the specific process of js ob...