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;width: 300px;height: 50px;}
span{position:absolute;margin-top: 10px;margin-left: 120px;}
img{width: 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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM