<input type="checkbox" name="hobby">吃飯
<input type="checkbox" name="hobby">睡覺
<input type="checkbox" name="hobby">打豆豆css
以上是經常使用的input複選框用法。
咱們能夠利用複選框點擊—選中,再點擊-不選中的特色製做開關。
開關效果,裏面不只有效果圖,也有代碼,左上角的html和css能夠點擊查看喔!!!!html
<input type="radio" name="gender">男
<input type="radio" name="gender">女code
以上是經常使用的input單選框用法。
咱們能夠利用單選框只能選中其中一個製做輪播圖。htm
輪播圖效果
因爲代碼比較長,就粘貼下。three
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <style> input{ display: none; } ul{ margin: 0; padding: 0; list-style: none; } #box{ width: 500px; height: 500px; margin: 0 auto; border:5px solid black; /*超出部分隱藏*/ overflow: hidden; position: relative; text-align: center; } .list{ /*讓ul橫着排放超出box*/ width: 400%; /*利用position:absolute不佔位*/ position: absolute; /*過渡執行時間爲1s*/ transition:1s; } .list li{ float:left; width: 500px; height: 500px; } label{ width: 10px; height: 10px; border-radius: 50%; border: 5px solid white; position: absolute; bottom:40px; z-index: 2; } /*設置每一個圓圈的位置*/ label:nth-of-type(1){ left:180px; } label:nth-of-type(2){ left:220px; } label:nth-of-type(3){ left:260px; } label:nth-of-type(4){ left:300px; } input:checked+label{ background:black; } /*選中移動ul*/ input:nth-of-type(1):checked~ul{ left:0; } input:nth-of-type(2):checked~ul{ left:-100%; } input:nth-of-type(3):checked~ul{ left:-200%; } input:nth-of-type(4):checked~ul{ left:-300%; } </style> </head> <body> <div id="box"> <input checked type="radio" name="pic" id="one"> <label for="one"></label> <input type="radio" name="pic" id="two"> <label for="two"></label> <input type="radio" name="pic" id="three"> <label for="three"></label> <input type="radio" name="pic" id="four"> <label for="four"></label> <ul class="list"> <li style="background: red;"></li> <li style="background: blue;"></li> <li style="background: yellow;"></li> <li style="background: brown"></li> </ul> </div> </body> </html>