样式复选框使用HTML和CSS

时间:2014-02-16 06:08:25

标签: html css

我真的不喜欢Chromes复选框的外观,所以我尝试使用css设计它,但我想它不起作用。

enter image description here

input[type="checkbox"]
    {
    border: 2px solid black;
    outline: 0;
    background: transparent;

}

2 个答案:

答案 0 :(得分:0)

HTML

<input type="checkbox" class="customCheckBox large" />

CSS

    .customCheckBox[type="checkbox"]:after{
        position: relative;
        display: block;
        left: 2px;
        top: -11px;
        width: 7px;
        height: 7px;
        border-width: 1px;
        border-style: solid;
        border-color: #B3B3B3 #dcddde #dcddde #B3B3B3;
        content: "";
        background-repeat: no-repeat;
        background-position:center;
    }

    .customCheckBox[type="checkbox"]:before{
        border: 1px solid #808080;
        content: "";
        background: #FFF;
        position: relative;
        display: block;
        width: 11px;
        height: 11px;

    }
    .customCheckBox[type="checkbox"]:checked:after{
        background-image:  url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAQAAABuW59YAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAB2SURBVHjaAGkAlv8A3QDyAP0A/QD+Dam3W+kCAAD8APYAAgTVZaZCGwwA5wr0AvcA+Dh+7UX/x24AqK3Wg/8nt6w4/5q71wAAVP9g/7rTXf9n/+9N+AAAtpJa/zf/S//DhP8H/wAA4gzWj2P4lsf0JP0A/wADAHB0Ngka6UmKAAAAAElFTkSuQmCC');
    }
    /* Large checkboxes */
    .customCheckBox.large{
        height:22px;
        width: 22px;
    }

    .customCheckBox.large[type="checkbox"]:before{
        width: 20px;
        height: 20px;
    }
    .customCheckBox.large[type="checkbox"]:after{
        top: -20px;
        width: 16px;
        height: 16px;
    }

给大班,因为你可能想在你的css或大小的复选框中添加一种类型的样式: - )

答案 1 :(得分:0)