hover无效果
鼠标放上去,无效果变化
解决:首先hover是可以对任何的元素设置效果,但必须是
最内层
最内层
最内层的元素:hover{ xxx}
如下案例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#test-hover{
color:rgb(101, 174, 243);
}
#test-hover:hover{ /*无效果,因为不是最内层元素*/
color:orange;
}
</style>
</head>
<body>
<div id="test-hover"><a href="javascript:console.log('xxxx');">测试hover</a></div>
</body>
</html>
伪元素:
::before ::after
ul 无序列表项居中的问题
- ul 取消列表样式后,默认还有内边距,取消内边距后,li项目才可以居中;
- 设置li项目的间隔,采用padding
设置块元素内容的垂直居中
/* 必须设置 px 像素, 百分比无效 */
h1{
height: 10%;
line-height: 60px; /* 父容器 高度600 设置10% 无效 必须设置像素*/
padding-top: 0%;
background-color: lightpink;
}