请问为什么设置font后P标签里的字就不能水平居中了
<!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>
* {
margin: 0;
padding: 0;
}
.transition-test1 .test1-box1{
width: 500px;
height: 400px;
margin:40px auto;
position: relative;
overflow: hidden;
}
.transition-test1 .test1-box1 img{
width: 500px;
height: 400px;
}
.transition-test1 .test1-box1 p{
position: absolute;
bottom: 0;
width: 500px;
height: 80px;
line-height: 80px;
color: white;
text-align: center;
/* 设置后不能垂直居中??? */
/* font:20px/1.5 Arial,"微软雅黑"; */
background-color:rgba(200, 200, 200, .7);
transition: opacity 1s ease 0s;
opacity: 0;
}
.transition-test1 .test1-box1:hover p{
opacity: 1;
}
</style>
</head>
<body>
<!-- /* 动画过渡 */ -->
<section class="transition-test1">
<div class="test1-box1">
<img src="headerimages/duck.png" alt="">
<p>这是一只小黄鸭</p>
</div>
</section>
</body>
</html>





恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星