<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>填充</title>
<style type="text/css">
#box1{
text-align:center;
word-wrap:break-word;
width:100px;
height:100px;
padding:10px;
border:5px solid white;
margin:auto;
background:red;
}
body{
background:blue;
}
</style>
</head>
<body>
<div id="box1">盒子盒子盒子盒子盒子盒子
</div>
</body>
</html>
4 回答
刚毅87
TA贡献345条经验 获得超309个赞
单行文字 :line—height:100px
多行文字,你参考一下.
方法一:
#box1{
display: flex;
justify-content: center;
align-items: center;
}方法二:
给文字加个标签,例如 p 标签
#box1{
position:relative
p{
position:absolute;
top:50%;
margin-top:XXXpx;
}
XXX为文字高度的一半- 4 回答
- 0 关注
- 1838 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消
