首页 > 代码库 > css3 实现切换显示隐藏效果

css3 实现切换显示隐藏效果

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Switch</title>
<style>
#chk{
display:none;
}

.box{
display:none;
width:100px;
height:100px;
background:#FF00DD;
}

#chk:checked ~.box{
display:block;
}
</style>
</head>
<body>
 
<label for="chk">hello</label>
<input type="checkbox" id="chk">
<div class="box">

</div>

</body>
</html>

css3 实现切换显示隐藏效果