RSS
热门关键字:  CSS教程  CSS布局  CSS样式  CSS hack  CSS JS
当前位置 :| 主页>CSS实例>

超炫的单选框与复选框效果

来源:cssplay 作者:cssplay 时间:2008-08-18 点击:

  在DIV+CSS构建的网页中,表单一直是一个比较头疼的问题,表单的布局与样式的定义还需要更多的学习与思考,今天介绍一款CSS表单,超炫的单选框与复选框效果。非常棒的感觉,希望对大家以后的布局有参考意义。


  我们看正常情况下此表单的效果:

超炫的单选框与复选框效果

  我们看经过CSS样式定义后的效果:

超炫的单选框与复选框效果

  实现这样的效果,作者除了对表单元素进行样式定义,还用JS对其进行了控制。


示例代码运行框如下:


 提示:您可以先修改部分代码再运行


我们看下面的CSS代码:

/* Off state for a ARC checkbox */
#labcontent .checkboxOff {
    display: inline;
    margin: 0px;
    padding: 2px; /* NS 6 problem */
    padding-left: 20px;
    color: #666;
    line-height: 16px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: .8em;
    background-image: url(checkbox_off.gif);
    background-repeat: no-repeat;
    background-position: 0% 50%;
    border: 0px;
}
/* On state for a ARC checkbox */
#labcontent .checkboxOn {
    display: inline;
    margin: 0px;
    padding: 2px; /* NS 6 problem */
    padding-left: 20px;
    color: #000;
    line-height: 16px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: .8em;
    background-image: url(checkbox_on.gif);
    background-repeat: no-repeat;
    background-position: 0% 50%;
    border: 0px;
}


/* Off state for a ARC checkbox */
#labcontent .altCheckboxOff {
    display: inline;
    padding: 20px 2px; /* NS 6 problem */
    padding-left: 70px;
    color: #666;
    line-height: 60px;
    font-family: "Courier New", Courier, mono;
    font-size: 1.2em;
    background-image: url(alt_checkbox_off.gif);
    background-repeat: no-repeat;
    background-position: 0% 50%;
    border: 0px;
    cursor: pointer;
}
/* On state for a ARC checkbox */
#labcontent .altCheckboxOn {
    display: inline;
    padding: 20px 2px; /* NS 6 problem */
    padding-left: 70px;
    color: #000;
    line-height: 60px;
    font-family: "Courier New", Courier, mono;
    font-size: 1.2em;
    font-weight: bold;
    background-image: url(alt_checkbox_on.gif);
    background-repeat: no-repeat;
    background-position: 0% 50%;
    border: 0px;
}


/* Off state for a ARC radio button */
.radioOff {
    display: inline;
    margin: 0px;
    padding: 2px;
    padding-left: 20px;
    color: #666;
    font: .8em/16px Verdana,Arial,Helvetica;
    background: transparent url(off.gif) no-repeat 0% 50%;
}
/* On state for a ARC radio button */
.radioOn {
    display: inline;
    margin: 0px;
    padding: 2px; /* NS 6 problem */
    padding-left: 20px;
    color: #000;
    font: .8em/16px Verdana,Arial,Helvetica;
    background: transparent url(on.gif) no-repeat 0% 50%;
}
/* use CSS to full effect with hover states. Ohhh, perty! */
.radioOn:hover {
    background-image: url(on_hover.gif);
}
.radioOff:hover {
    color: #333 !important;
    background-image: url(off_hover.gif);
}

/* Alternative Off state for a ARC radio button */
.altRadioOff {
    display: inline;
    margin: 0px;
    padding: 2px;
    padding-left: 20px;
    color: #000;
    line-height: 16px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 0.8em;
    background-image: url(alt_off.gif);
    background-repeat: no-repeat;
    background-position: 0% 50%;
    border: 0px;
    cursor: pointer;
}
/* Alternative On state for a ARC radio button */
.altRadioOn {
    display: inline;
    margin: 0px;
    padding: 2px; /* NS 6 problem */
    padding-left: 20px;
    line-height: 16px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: .8em;
    background-image: url(alt_on.gif);
    background-repeat: no-repeat;
    background-position: 0% 50%;
    border: 0px;
    cursor: pointer;
    text-decoration: underline;
}


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
热点实例