remix1911
2016-03-17 21:38
<style type="text/css">
#box1{
width:100px;
height:100px;
padding:10px;
border:1px solid red;
text-align:center;
background:red;
}
</style>
</head>
<body>
<div id="box1">盒子1</div>
box1里面加个样式 line-height:100px;
<style type="text/css">
#box1{
width:100px;
height:100px;
padding:10px;
border:1px solid red;
text-align:center;
background:red;
line-height:100px;
}
</style>
</head>
<body>
<div id="box1" text-align:center;>盒子1</div>
</body>
padding:50%;
<style type="text/css"> #box1{ width:100px; height:100px; padding:10px; border:1px solid red; text-align:center; background:red; margin:auto auto; } </style> </head> <body> <div id="box1" text-align:center;>盒子1</div> </body>
center
text-align:center;
默认情况下,我们给盒子设置maring、padding和border的时候,不管设置的是什么单位的值,这些值都会计算在盒子的总体面积以内
初识HTML(5)+CSS(3)-升级版
1228570 学习 · 19080 问题
相似问题