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>
posted @ 2017-05-21 21:46  JonasYu  阅读(6850)  评论(0编辑  收藏  举报