我是打算放個圖片,然后checkbox定位上去設(shè)置為透明,你們都是怎么做這種的,求哥哥指導(dǎo)一下
之前剛好做了一個,我用的不是圖標(biāo),是自己繪制的,和樓上上的方法一樣
效果圖是這樣,你可以自己修改顏色啥的:
代碼如下,直接復(fù)制就可以實現(xiàn)了:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>demo</title>
<style>
.label{position: relative;}
.input{display:none}
.span{display: inline-block;width: 16px;height: 16px;border: 1px solid #fd8845;}
.input:checked+.span:after{
content: "";
position: absolute;
width: 9px;
height: 4px;
border: 2px solid #fd8845;
border-top-color: transparent;
border-right-color: transparent;
-ms-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-webkit-transform: rotate(-60deg);
transform: rotate(-45deg);}
</style>
</head>
<body>
<div>
<label class="label">
<input class="input" type="checkbox" name="">
<span class="span"></span>
</label>
</div>
</body>
</html>
也可以看看我總結(jié)的步驟:
改變checkbox和radio的默認(rèn)樣式
更換了一種可以兼容大多數(shù)瀏覽器的方法
<style>
/*裁剪隱藏原生input*/
.checkbox{ position: absolute;clip: rect(0, 0, 0, 0);}
/*label模擬input*/
label{position:relative; display:inline-block; width: 20px;height: 20px;background: #fff;border: 1px solid #f03e3e;}
/*勾選后更改背景*/
.checkbox:checked + label{background:#f03e3e;}
/*用偽類模擬勾選狀態(tài)的勾,大小位置可調(diào)*/
.checkbox:checked + label:before{content: "";font-family: Muiicons;font-size: 18px;font-weight: 400;color: #fff;text-decoration: none;background: 0 0;border-radius: 0;opacity: 1;border: 2px solid #fff;border-top: none;border-right: none;-webkit-transform: rotate(-45deg);transform: rotate(-45deg);-webkit-font-smoothing: antialiased;left: 3px;top: 3px;position: absolute;width: 10px;height: 6px;}
</style>
<input type="checkbox" class="checkbox" id="checkbox"/>
<label for="checkbox"></label>
以下方法只兼容chrome,firefox,360等,ie版本不兼容,適用于web端
用偽類,具體樣式可以自己調(diào)整
<style>
.checkbox{position: relative;display: inline-block;width: 20px;height: 20px;-webkit-appearance: none;-moz-appearance: none;background: #fff;border: 1px solid #f03e3e;outline: 0!important;}
.checkbox:checked{background: #f03e3e; border: 1px solid #f03e3e;}
.checkbox:checked:before{content: "";font-family: Muiicons;font-size: 18px;font-weight: 400;color: #fff;text-decoration: none;background: 0 0;border-radius: 0;opacity: 1;border: 2px solid #fff;border-top: none;border-right: none;-webkit-transform: rotate(-45deg);transform: rotate(-45deg);-webkit-font-smoothing: antialiased;left: 3px;top: 3px;position: absolute;width: 10px;height: 6px;}
</style>
<input type="checkbox" class="checkbox" />
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。