定的padding為10px,為什么感覺文字下面感覺比其他幾面短些,來個神解釋下
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>填充</title>
<style type="text/css">
#box1{
background:green;
width:100px;
height:100px;
padding:100px;
border:1px solid red;
</style>
</head>
<body>
<div id="box1">盒子1盒子盒子盒子盒子盒子盒子盒子盒子盒盒子盒子盒盒子盒子盒盒子盒子盒盒子盒子盒子盒</div>
</body>
</html>
2017-09-11
其實是正常的,只是因為你的div設(shè)置的太小了,文字超出div的邊界,圖中最中間的藍(lán)色小方塊就是div區(qū)域,綠色區(qū)域是padding
或者你在div中加一個文本域就會顯示正常了,代碼如下:
2017-09-10
1只占一個字符 每個漢字占2個字符 被擠下去了 ?你加一個text-align: center;就好了
2017-09-10
text-align: center;