欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

純CSS實(shí)現(xiàn)radio和checkbox實(shí)現(xiàn)效果示例

  發(fā)布時(shí)間:2018-04-18 15:55:34   作者:夜里的太陽   我要評(píng)論
這篇文章主要介紹了純CSS實(shí)現(xiàn)radio和checkbox實(shí)現(xiàn)效果示例的相關(guān)資料,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

radio-and-checkbox

純CSS實(shí)現(xiàn)radio和checkbox實(shí)現(xiàn)效果

reset-radio

在開發(fā)PC端的項(xiàng)目時(shí),經(jīng)常會(huì)用到radio和checkbox組件,可是因?yàn)樵臉邮较鄬?duì)來說不符合設(shè)計(jì)師的設(shè)計(jì)風(fēng)格,所以我們可能會(huì)經(jīng)常引用第三方的模塊去實(shí)現(xiàn),或者通過JS等其他方式去hack。這樣相對(duì)來說增加了代碼量不說,還特別復(fù)雜,所以才有了這個(gè)純CSS依賴原生input[radio]和input[checkbox]的實(shí)現(xiàn)方式,主要代碼如下:

html主要代碼

<div class="reset-radio">
    <input checked type="radio" id="age1" name="age">
    <span class="real-target"></span>
</div>

CSS代碼,這里主要是通過一個(gè)子節(jié)點(diǎn)span去配合input:checked兄弟選擇器,來修改樣式

.reset-radio {
    display: inline-block;
    position: relative;
    width: 16px;
    height: 16px;
}

.reset-radio .real-target {
    z-index: 1;
    width: 100%;
    height: 100%;
    position: absolute;
    display: inline-block;
    background: #ffffff;
    border: 1px solid #dadde0;
    border-radius: 100%;
    top: 0;
    left: 0;
    bottom: 0;
}

.reset-radio input[type=radio] {
    cursor: pointer;
    z-index: 2;
    width: 16px;
    height: 16px;
    opacity: 0;
    position: absolute;
    left: 0;
    top: 0;
    margin: 0;
    right: 0;
    bottom: 0;
}

.reset-radio input:checked+span {
    border-color: #48b4ec;
}

.reset-radio input:checked+span::before {
    content: '';
    position: absolute;
    background: #48b4ec;
    width: 6px;
    height: 6px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 100%;
}

reset-checkbox

reset-checkbox原理是一樣的就不在贅述了。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論