HTML代碼結構如下:1 2 7 8 9 14
css代碼如下:1 label { /*設置label的樣式*/ 2 width: 100%; 3 padding: 10px 0px; 4 display: block; 5 line-height: 20px; 6 position: relative; 7 font-weight: normal; 8 } 9 .radio .option { /*把優化后的按鈕圖片設置為該div的背景圖片,把該div定位到原生樣式的上方,遮蓋住原生樣式。*/10 width: 25px;11 height: 25px;12 position: absolute;13 top: 10px;14 left: 0px;15 background-size: cover;16 background: url(img/radio.png) no-repeat;17 background-size: cover;18 }19 .radio input[type="radio"] { /*為了保險起見,把原生樣式隱藏掉*/20 display: inline-block ;21 margin-right: 15px ;22 opacity: 0 ;23 }24 input[type="radio"]:checked+div { /*當radiuo被選中時,把input下邊的div標簽的背景圖片替換掉*/25 background: url(img/radio-checked.png) no-repeat;26 background-size: cover;27 }
最后貼上一張效果圖:
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com