1, the middle dot uses the gradient attribute of the CSS3
2, the transition attribute of motion to CSS3
3, need to write the compatibility of each browser
The code is as follows
1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>CSS3 button</title>6 </Head>7 <styletype= "Text/css">8 . BTN{9 width:100px;Ten Height:30px; One background:Orange; A Border-radius:20px; - position:relative; - the } - . BTN Input{ - width:100%; - Height:100%; + Opacity:0; - cursor:Pointer; + } A . BTN Label{ at Display:Block; - width:20px; - Height:20px; - background:-webkit-linear-gradient (Top, #fff, #ccc); - background:-moz-linear-gradient (Top, #fff, #ccc); - background:-ms-linear-gradient (Top, #fff, #ccc); in background:-o-linear-gradient (Top, #fff, #ccc); - position:Absolute; to Left:10px; + Top:5px; - -webkit-transition:All . 2s linear; the -moz-transition:All . 2s linear; * -ms-transition:All . 2s linear; $ -o-transition:All . 2s linear;Panax Notoginseng transition:All . 2s linear; - cursor:Pointer; the Border-radius:50%; + } A . BTN Input:checked+label{ the Left:70px; + } - </style> $ <Body> $ <Divclass= "BTN"> - <inputtype= "checkbox"ID= "Forbtn"> - <label for= "Forbtn"></label> the </Div> - </Body>Wuyi </HTML>
The. Btn Input:checked+label indicates that the label tag behind it defines the style when input is selected.
CSS3 Making scroll buttons