p标签中的文字垂直居中

确定好p标签的位置后,<p><span>这是美女</span></p>,在p标签中加一个span标签,设置span的css时根据p标签的长宽计算好span的margin-top即可

示例代码:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style>
li{list-style:none;}
p{position: absolute;top: 0px;left: 48px;background-color: darkgrey; 300px;height: 50px;}
span{position:absolute;margin-top: 10px;margin-left: 120px;}
img{ 300px;height:300px;margin: 0px;padding: 0px;}
</style>
<script>

</script>
</head>
<body>
<ul>
<li>
<img src="img/1.jpg">
</li>
<li></li>
</ul>
<p><span>这是美女</span></p>
</body>
</html>

本人小白,博客作为在线笔记,若有错误,还望指出,转载链接截图等皆为学习,若有侵权,请告知,
原文地址:https://www.cnblogs.com/xiaoxiaoyao/p/7659392.html