如何在選擇列表中添加圖像?我有一份性別選擇列表。代碼:<select><option>male</option><option>female</option><option>others</option></select>我想使用下拉列表中的圖像作為下拉列表。我想添加一個(gè)按鈕代替下拉圖標(biāo)。怎么做?
3 回答

MM們
TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊
<select> <option style="background-image:url(male.png);">male</option> <option style="background-image:url(female.png);">female</option> <option style="background-image:url(others.png);">others</option></select>
HTML
<select id="gender"> <option>male</option> <option>female</option> <option>others</option></select>
CSS
select#gender option[value="male"] { background-image:url(male.png); }select#gender option[value="female"] { background-image:url(female.png); }select#gender option[value="others"] { background-image:url(others.png); }

肥皂起泡泡
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊
<select name='state' style='height: 45px; font-family:Arial, FontAwesome;'><option value=''> All States</option> <option value='enabled' style='color:green;'> Enabled</option><option value='paused' style='color:orange;'>  Paused</option><option value='archived' style='color:red;'> Archived</option></select>
注意 字體系列:Arial,F(xiàn)ontAwome;需要按樣式分配,以便選擇,就像在示例中給出的一樣!
添加回答
舉報(bào)
0/150
提交
取消