题目如图:
解答代码如下:
<html>
<head>
<style>
div{
height:100px;
width:60px;
float:left;
margin-left:100px;
font-size:24px;
font-weight:bold;
line-height:100px;
color:white;
background-color:black;
text-align:center;
}
</style>
</head>
<body>
<main>
<div>A</div>
<div>B</div>
<div>C</div>
</main>
</body>
</html>
我实现的效果如图:
这道题应该考察的是居中对齐,将文本的line-height
设为容器等高就能上下居中,text-align
设为center
就实现了左右居中。