<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div align="center" style="width: 300px; height: 200px; background-color: #0098ff;">
<body>
<span style="color: #ffffff; line-height: 200px;">居中的标签</span>
</div>
</body>
</html>
在这段代码中,除了在div中设置align="center"还要对其中的span设置line-height高度等于div高度
逼死强迫症,搞定div中内容居中
最新推荐文章于 2024-08-04 21:23:42 发布