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