第一步:使用font-face聲明字體web
@font-face {font-family: 'iconfont'; src: url('iconfont.eot'); /* IE9*/ src: url('iconfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('iconfont.woff') format('woff'), /* chrome、firefox */ url('iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('iconfont.svg#uxiconfont') format('svg'); /* iOS 4.1- */ }
第二步:定義使用iconfont的樣式chrome
.iconfont{ font-family:"iconfont" !important; font-size:16px;font-style:normal; -webkit-font-smoothing: antialiased; -webkit-text-stroke-width: 0.2px; -moz-osx-font-smoothing: grayscale;}
第三步:挑選相應圖標並獲取字體編碼,應用於頁面svg
<i class="iconfont">3</i>
第四步:字體圖標的應用字體
.checkbox input, .radio input { display: none;} /*inputy隱藏*/ .radio label:before{ content: "\e60e";}/*默認單選框的樣式*/ .checkbox label:before{ content: "\f0011";}/*默認複選框的樣式*/ .radio label:hover:before {content: "\e60f";}/*鼠標浮動上單選框樣式*/ .checkbox label:hover:before {content: "\f0012";}/*鼠標浮動上覆選框樣式*/ .radio input:checked + label:before { content: "\e60f";}/*鼠標浮點擊後單選框樣式*/ .checkbox input:checked + label:before { content: "\f0012";}/*鼠標浮點擊後複選框樣式*/
HTML:編碼
<span class="checkbox"> <input type="checkbox" id="checkbox1" name="ckeckbox" /> <label for="checkbox1" class="iconfont"></label>貨幣基金 </span> <span class="checkbox"> <input type="checkbox" id="checkbox2" name="ckeckbox" /> <label for="checkbox2" class="iconfont"></label>基金定投 </span>
<span class="radio"><input type="radio" id="radio19" name="radio4" /><label for="radio19" class="iconfont"></label>很是滿意 </span> <span class="radio"><input type="radio" id="radio20" name="radio4" /><label for="radio20" class="iconfont"></label>比較滿意 </span> <span class="radio"><input type="radio" id="radio21" name="radio4" checked="checked" /><label for="radio21" class="iconfont"></label>通常 </span> <span class="radio"><input type="radio" id="radio22" name="radio4" /><label for="radio22" class="iconfont"></label>不太滿意 </span> <span class="radio"><input type="radio" id="radio23" name="radio4" /><label for="radio23" class="iconfont"></label>很不滿意 </span>
最終效果展現:url