checkbox_label选中变化

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
 
 
 
#apDiv1 {
    position: absolute;
    width: 200px;
    height: 115px;
    z-index: 1;
    left: 107px;
    top: 121px;
    background-color: #CCCCCC;

 
 
#lab_id:before{
    content: '1';
    background-color:yellow;
}

#lab_id:after{
    content: '2';
    background-color:gray;
}
 

#checked_1:checked~label{
    background-color:red;
}

#checked_1:checked~label:before{
    background-color:blue;
}
#checked_1:checked~label:after{
    background-color:pink;
}

</style>
</head>

<body>

 
<div id="apDiv1">
 <input id="checked_1" type="checkbox"  />
  <label id="lab_id" for="checked_1">a</label>
  </div> 

 
</body>
</html>

猜你喜欢

转载自blog.csdn.net/ozhy111/article/details/84329633