我在表格中有一個復選框列表。(行中的一些CB) <tr><td><input type="checkbox" class="custom_image" value="1" id="CB1" /><label for='CB1'> </label></td></tr> <tr><td><input type="checkbox" class="custom_image" value="2" id="CB2" /><label for='CB2'> </label></td></tr> <tr><td><input type="checkbox" class="custom_image" value="3" id="CB3" /><label for='CB3'> </label></td></tr> <tr><td><input type="checkbox" class="custom_image" value="4" id="CB4" /><label for='CB4'> </label></td></tr>我想用一對自定義的開/關圖像替換復選框圖像,我想知道是否有人更好地理解如何使用CSS做到這一點?我找到了這個“CSS忍者”教程,但我不得不承認我覺得它有點復雜。 http://www.thecssninja.com/css/custom-inputs-using-css據我所知,你被允許使用偽類 td:not(#foo) > input[type=checkbox] + label { background: url('/images/off.png') 0 0px no-repeat; height: 16px; padding: 0 0 0 0px; }我的期望是,通過添加上面的CSS,復選框至少會默認顯示處于OFF狀態的圖像,然后我會添加以下內容以獲得ON td:not(#foo) > input[type=checkbox]:checked + label { background: url('/images/on.png') 0 0px no-repeat; }不幸的是,我似乎錯過了某個關鍵步驟。我試圖使用自定義CSS3選擇器語法來匹配我當前的設置 - 但必須丟失一些東西(如果重要的話,圖像大小為16x16)http://www.w3.org/TR/css3-selectors/#checked編輯:我在教程中遺漏了一些內容,他將圖像更改應用于標簽而不是輸入本身。我仍然沒有在頁面上獲得預期的交換圖像以獲得復選框結果,但我認為我更接近了。
- 3 回答
- 0 關注
- 817 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消