這個其實是js插件模擬的,大致思路是這樣子的
創(chuàng)新互聯(lián)專注于企業(yè)成都全網(wǎng)營銷、網(wǎng)站重做改版、商都網(wǎng)站定制設計、自適應品牌網(wǎng)站建設、HTML5建站、商城網(wǎng)站建設、集團公司官網(wǎng)建設、外貿(mào)網(wǎng)站建設、高端網(wǎng)站制作、響應式網(wǎng)頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為商都等各大城市提供網(wǎng)站開發(fā)制作服務。
先將checkbox隱藏
模擬一個checkbox,其實是div之類的元素,加上背景圖片,在將執(zhí)行選中事件時,就將這個模擬的checkbox添加或移除對應的CSS樣式就可以,然后根據(jù)選擇事件去操作原本隱藏的checkbox
這類的jq插件比較多!給你參考:
給你看一段超炫的CSS3代碼:是關于checkbox的。
style
*{
margin:0;
padding:0;
}
body{
background-color:#202838;
}
.switch{
width:180px;
height:55px;
position:relative;
margin:100px?auto;
}
.switch?input{
filter:?alpha(opacity=0);
opacity:?0;
z-index:?100;
position:?absolute;
width:?100%;
height:?100%;
cursor:?pointer;
}
.switch?label{
display:block;
width:80%;
height:100%;
position:?relative;
background:?linear-gradient(#121823,?#161d2b);
border-radius:?30px?30px?30px?30px;
box-shadow:
???inset?0?3px?8px?1px?rgba(0,0,0,0.5),
???inset?0?1px?0?rgba(0,0,0,0.5),
???0?1px?0?rgba(255,255,255,0.2);
-webkit-transition:?all?0.5s?ease;
transition:?all?0.5s?ease;
}
.switch?label?i{
display:block;
width:51px;
height:51px;
position:absolute;
left:2px;
top:2px;
z-index:2;
border-radius:50%;
background:?linear-gradient(#36455b,?#283446);
box-shadow:
inset?0?1px?0?rgba(255,255,255,0.2),
0?0?8px?rgba(0,0,0,0.3),
0?12px?12px?rgba(0,0,0,0.4);
-webkit-transition:?all?0.5s?ease;
transition:?all?0.5s?ease;
}
.switch?span?{
content:?"";
display:?inline-block;
position:?absolute;
right:?0px;
top:?17px;
width:?18px;
height:?18px;
border-radius:?10px;
background:?gradient-gradient(#36455b,?#283446);
box-shadow:
inset?0?1px?0?rgba(0,0,0,0.2),
0?1px?0?rgba(255,255,255,0.1),
0?0?10px?rgba(185,231,253,0),
inset?0?0?8px?rgba(0,0,0,0.9),
inset?0?-2px?5px?rgba(0,0,0,0.3),
inset?0?-5px?5px?rgba(0,0,0,0.5);
-webkit-transition:?all?0.5s?ease;
transition:?all?0.5s?ease;
z-index:?2;
}
.switch?input:checked?~?span{
content:?"";
display:?inline-block;
position:?absolute;
width:?18px;
height:?18px;
border-radius:?10px;
-webkit-transition:?all?0.5s?ease;
transition:?all?0.5s?ease;
z-index:?2;
background:?#b9f3fe;?
background:?gradient-gradient(#ffffff,?#77a1b9);
box-shadow:????????
??inset?0?1px?0?rgba(0,0,0,0.1),
??0?1px?0?rgba(255,255,255,0.1),
??0?0?10px?rgba(100,231,253,1),
??inset?0?0?8px?rgba(?61,157,247,0.8),
??inset?0?-2px?5px?rgba(185,231,253,0.3),
??inset?0?-3px?8px?rgba(185,231,253,0.5);
}
.switch?input:checked?~?label?i?{
left:?63%;
box-shadow:
inset?0?1px?0?rgba(255,255,255,0.2),
0?0?8px?rgba(0,0,0,0.3),
0?8px?8px?rgba(0,0,0,0.3),
inset?-1px?0?1px?#b9f3fe;
-webkit-transition:?all?.5s?ease;
transition:?all?.5s?ease;
}
/style
body????
div?class="switch"????
input?type="checkbox"?name="toggle"????
label?for="toggle"i/i/label????
span/span????
/div????
/body
給你說個思路吧:用圖片代替復選框,單擊替換圖片為被選擇中的圖片,再單擊則還原回最初的圖片。唯一需要注意的是統(tǒng)計復選框數(shù)量有點麻煩。單純依靠CSS定義估計很難,CSS不能控制圖片的SRC屬性。用JS吧。。。JS沒那么討厭的~
1、首先,需要添加一段CSS隱藏所有的Checkbox復選框。要做到點需要添加一段代碼到你的CSS文件中。代碼如下:
/*** 隱藏默認的checkbox***/
input[type=checkbox] {
visibility: hidden;
}
2、開始創(chuàng)建復選框區(qū)的HTML。代碼如下:
section
!-- Checbox One --
h3Checkbox One/h3
div class="checkboxOne"
input type="checkbox" value="1" id="checkboxOneInput" name="" /
? label for="checkboxOneInput"/label
/div
/section
3、用一個DIV元素包含checkbox,使用它們來做黑色條帶和圓角。代碼如下:
/*** Create the slider bar***/
.checkboxOne {
width: 40px;
height: 10px;
background: #555;
margin: 20px 80px;
position: relative;
border-radius: 3px;
}
4、當選中復選框后的判定代碼。代碼如下
/*** Move the slider in the correct position if the checkbox is clicked**/
.checkboxOne input[type=checkbox]:checked + label {
left: 27px;
}
復選框選中前。
復選框選中后。
1、打開網(wǎng)頁開發(fā)工具,新建一個HTML文件。
2、編寫HTML:表單復選框。
3、編寫CSS:復選框的樣式。
4、編寫CSS部分:復選框選中后的樣式。
5、最好打開瀏覽器預覽效果,滿意保存即可。
注意事項;
復選框提供一個制造單一選擇開關的方法;它包括一個小框和一個標簽。典型的復選框有一個小的“X”(或者它設置的其它類型)或是空的,這依靠項目是否被選擇來決定的。
這個不是樣式?jīng)Q定的,是有 type決定的
input type="***"
type="radio" 單選按鈕
type="checkbox" 復選框
下拉列表則是如下形式出現(xiàn)的
select name="cars"
option value="volvo"Volvo/option
option value="saab"Saab/option
option value="fiat"Fiat/option
option value="audi"Audi/option
/select
當前名稱:css改變復選框樣式,css修改復選框樣式
瀏覽地址:http://aaarwkj.com/article24/dssgeje.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信公眾號、、動態(tài)網(wǎng)站、自適應網(wǎng)站、品牌網(wǎng)站制作、品牌網(wǎng)站設計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)