佳木斯湛栽影视文化发展公司

主頁 > 知識(shí)庫 > 單選按鈕、多選按鈕用圖片實(shí)現(xiàn)加樣式

單選按鈕、多選按鈕用圖片實(shí)現(xiàn)加樣式

熱門標(biāo)簽:百度競價(jià)點(diǎn)擊價(jià)格的計(jì)算公式 硅谷的囚徒呼叫中心 網(wǎng)站建設(shè) 檢查注冊表項(xiàng) 使用U盤裝系統(tǒng) 智能手機(jī) 阿里云 美圖手機(jī)
之前一直看到有人在問,單選按鈕和多選按鈕怎么加樣式、怎么把按鈕變大?下面把我做的一個(gè)例子分享出來。

1.首先把按鈕做成圖片
 

2.html頁面

復(fù)制代碼
代碼如下:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(function(){
$("input[type='checkbox']").click(function(){
if($(this).is(':checked')){
$(this).attr("checked","checked");
$(this).parent().removeClass("c_off").addClass("c_on");
}else{
$(this).removeAttr("checked");
$(this).parent().removeClass("c_on").addClass(" c_off");
}
});
$("input[type='radio']").click(function(){
$("input[type='radio']").removeAttr("checked");
$(this).attr("checked","checked");
$(this).parent().removeClass("r_off").addClass("r_on").siblings().removeClass("r_on").addClass("r_off");
});
});
</script>
</head>
<style>
/* 多選/單選 */
label {
display: block;
cursor: pointer;
line-height: 26px;
margin-bottom: 20px;
width: 26px;
height: 26px;
line-height: 26px;
float: left;
margin-top: 6px;
}
.radios {
padding-top: 18px;
border-top: 1px solid #049CDB;
}
.label_check input, .label_radio input {
margin-right: 5px;
}
.lblby .label_check, .lblby .label_radio {
margin-right: 8px;
}
.lblby .label_radio, .lblby .label_check {
background: url(../images/jxc_btn.png) no-repeat;
}
.lblby .label_check {
background-position: 0 0px
}
.lblby label.c_on {
background-position: 0 -26px;
}
.lblby .label_radio {
background-position: 0 -52px;
}
.lblby label.r_on {
background-position: 0 -78px;
}
.lblby .label_check input, .lblby .label_radio input {
position: absolute;
left: -9999px;
}
</style>
<body class="lblby">
<label for="checkbox-01" class="label_check c_on">
<input type="checkbox" checked="checked" value="1" id="checkbox-01" name="sample-checkbox-01" />
Checkbox1 </label>
<label for="checkbox-02" class="label_check">
<input type="checkbox" value="1" id="checkbox-02" name="sample-checkbox-02" />
Checkbox2</label>
<label for="radio-01" class="label_radio r_on">
<input type="radio" value="1" checked="checked" id="radio-01" name="sample-radio" />
Radio1 </label>
<label for="radio-02" class="label_radio r_off">
<input type="radio" value="1" id="radio-02" name="sample-radio" />
Radio2 </label>
<label for="radio-03" class="label_radio r_off">
<input type="radio" value="1" id="radio-03" name="sample-radio" />
Radio3 </label>
</body>
</html>

標(biāo)簽:湘潭 山南 通遼 湖北 煙臺(tái) 黃山 賀州 懷化

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《單選按鈕、多選按鈕用圖片實(shí)現(xiàn)加樣式》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    临泽县| 西畴县| 普兰店市| 宜昌市| 安阳市| 蓝山县| 漳平市| 达日县| 临安市| 收藏| 忻城县| 诸城市| 昌都县| 义乌市| 武威市| 开原市| 公安县| 兴和县| 东港市| 郸城县| 桂林市| 孟连| 临猗县| 平利县| 久治县| 丰原市| 余庆县| 冕宁县| 文登市| 浦江县| 浮山县| 英超| 雷波县| 聂荣县| 衢州市| 乌鲁木齐县| 阳原县| 阜康市| 于都县| 巫溪县| 巴青县|