100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > p标签中的文字垂直居中

p标签中的文字垂直居中

时间:2021-04-14 11:53:09

相关推荐

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>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。