CSS3复选框样式

时间:2013-09-24 04:44:02

标签: css css3 checkbox

我没有使用复选框样式的经验。无论如何都要在复选框上实现边框半径效果?如何设置此图像的复选框?

enter image description here

2 个答案:

答案 0 :(得分:8)

HTML

<div class="checkbox">  
        <input id="check1" type="checkbox" name="check" value="check1">  
        <label for="check1">Checkbox No. 1</label>  
        <br>  
        <input id="check2" type="checkbox" name="check" value="check2">  
        <label for="check2">Checkbox No. 2</label>  
    </div>

<强> CSS

label {
    display: inline-block;
    cursor: pointer;
    position: relative;
    padding-left: 25px;
    margin-right: 15px;
    font-size: 13px;
    margin-bottom: 10px;
}
label:before {
    content:"";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 10px;
    position: absolute;
    left: 0;
    bottom: 1px;
    background-color: #aaa;
    box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
    border-radius: 3px;
}
input[type=checkbox] {
    display: none;
}
input[type=checkbox]:checked + label:before {
    content:"\2713";
    text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
    font-size: 15px;
    color: #f3f3f3;
    text-align: center;
    line-height: 15px;
}

here

Fiddle

现代浏览器应该是什么样子。 What it should look like

答案 1 :(得分:2)

<div class="square">
<input type="checkbox" value="None" id="square" name="check" />
<label for="square"></label></div>

css3代码:

.square label {
 cursor: pointer;
 position: absolute;
 width: 20px;
 height: 20px;
 left: 4px;
 top: 4px;

 -webkit-box-shadow: inset 0px 1px 1px white, 0px 1px 0px white;
 border:1px solid lightblue;

  background: -webkit-linear-gradient(top, white 0%, white 100%);

   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#222', endColorstr='#45484d',GradientType=0 );   }

  .square label:after {
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
   filter: alpha(opacity=0);
   opacity: 0;
   content: '';
    position: absolute;
    width: 9px;
     height: 5px;
    background: transparent;
    top: 4px; 
     left: 4px;
      border: 3px solid blue;
      border-top: none;
     border-right: none;

     -webkit-transform: rotate(-45deg);
      -moz-transform: rotate(-45deg);
     -o-transform: rotate(-45deg);
       -ms-transform: rotate(-45deg);
         transform: rotate(-45deg);  }

 .square input[type=checkbox]:checked + label:after {
      -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
       filter: alpha(opacity=100);
         opacity: 1; }

我正在修改css代码...检查