checked选择器怎么用
更新:HHH   时间:2023-1-7


本篇内容主要讲解“checked选择器怎么用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“checked选择器怎么用”吧!

  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>


到此,相信大家对“checked选择器怎么用”有了更深的了解,不妨来实际操作一番吧!这里是天达云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

返回web开发教程...