欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  checked选择器是什么?
 
  在表单元素中,单选按钮radio和复选框checkbox都具有“选中”和“未选中”状态。在CSS3中,我们可以通过使用:checked选择器来定义选中时的CSS样式。
 
  暂时只有Opera浏览器支持:checked选择器。
 
  举例:
 
  
 
  <!DOCTYPEhtml>
 
  <htmlxmlns="http://www.w3.org/1999/xhtml">
 
  <head>
 
  <title>CSS3:checked选择器</title>
 
  <styletype="text/css">
 
  input:checked
 
  {
 
  background-color:red;
 
  }
 
  </style>
 
  </head>
 
  <body>
 
  <formname="form1"method="post"action="index.html">
 
  性别:
 
  <inputtype="radio"name="Question1"value="boy"checked="checked"/>男
 
  <inputtype="radio"name="Question1"value="girl"/>女<br/>
 
  你喜欢的水果:<br/>
 
  <inputid="checkbox1"type="checkbox"checked="checked"/><labelfor="checkbox1">苹果</label><br/>
 
  <inputid="checkbox2"type="checkbox"/><labelfor="checkbox2">香蕉</label><br/>
 
  <inputid="checkbox3"type="checkbox"/><labelfor="checkbox3">西瓜</label><br/>
 
  <inputid="checkbox4"type="checkbox"/><labelfor="checkbox4">凤梨</label>
 
  </form>
 
  </body>
 
  </html>






本文转载自中文网
 

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css3-style/c56566.shtml