我想将文本居中放在我创建的“人工”表格的单元格中间。(人工,因为它使用 div)
在 css 样式中,我添加了以下几行:
text-align:center;
vertical-align:middle;
这通常可以解决问题。在这种情况下,但他们没有。这是整个源代码:
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>asd</title>
<style>
body {
padding:0;
margin:0;
}
.Table {
position:absolute;
left:25px;
top:275px;
border:none;
width:650px;
height:40.99999px;
border-top:1px solid black;
border-left:1px solid black;
}
.Cell {
float:left;
width:107.3333px;
height:40px;
border-right:1px solid black;
border-bottom:1px solid black;
font-weight:bold;
text-align:center;
vertical-align:middle;
}
</style>
</head>
<body>
<div class="Table">
<div class="Cell ">Hello</div>
<div class="Cell ">Hello</div>
<div class="Cell ">hihi</div>
<div class="clear"></div>
<div class="Cell "></div>
<div class="Cell "></div>
<div class="Cell "></div>
</div>
</body>
</html>