超炫的单选框与复选框效果
我们看正常情况下此表单的效果:
实现这样的效果,作者除了对表单元素进行样式定义,还用JS对其进行了控制。
查看运行效果:
运行代码复制代码另存代码收藏本页
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
我们看下面的CSS代码:
#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;
}