您现在的位置:首页 >> 前端 >> 内容

hover中的小坑

时间:2017/1/25 10:23:45 点击:

  核心提示:html head title/title meta charset=UTF-8 / style type=text/css.box1 { width: 300px; height: 300px; b...
<html>
 <head> 
  <title></title> 
  <meta charset="UTF-8" /> 
  <style type="text/css">
.box1 {
	width: 300px;
	height: 300px;
	background: red;
}

.box1:hover {
	background: blue;
	// 鼠标放到box1上hover的时候可以把box1的'red'改为‘blue’
}
</style> 
 </head> 
 <body> 
  <p class="box1"> 
  </p>   ////////////// 
  <style type="text/css">
//下面只是改变了css样式, 
.box1 {
	width: 300px;
	height: 300px;
	background: red;
	display: none;
}

.box1:hover {
	//当把box1的display属性设置为none的时候,鼠标移动上去,不能改变display属性,
//box1还是不会出现
background: blue;
	display: block;
}

body:hover .box1 {
	//如果用box1的父级body 去hover box1此时可以把box1的display属性改为
//block
display: block;
}
</style>
 </body>
</html>

Tags:HO OV VE ER 
作者:网络 来源:WangXiaoYu