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
When compiling and installing Nginx, some modules...
Starting from this article, a new series of artic...
During the Olympic Games, IE 8 Beta 2 will be rele...
Let me share with you a creative opening realized...
Table of contents 1. Introduction 2. Install Dock...
1. Links Hypertext links are very important in HTM...
Operation effectCode Implementation html <div ...
A few days ago, when I was working on a requireme...
Some of you may have heard that the order of trav...
When the created tab label exceeds the visible ar...
First install the dependent packages to avoid pro...
Demand scenario: The boss asked me to use the cra...
Table of contents introduction 1. Code to start t...
Table of contents What is two-way data binding Im...
js interesting countdown case, for your reference...