Blogger Information
Blog 18
fans 0
comment 3
visits 12524
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
盒模型常用属性与盒大小计算方式
P粉019280626
Original
328 people have browsed it

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gao的作业-盒模型常用属性与盒大小计算方式</title>
</head>
<body>

  1. <div class="box">这是一个盒子</div>
  2. <style>
  3. * {
  4. margin: 0;
  5. padding: 0;
  6. /* box-sizing: border-box; */
  7. }
  8. .box{
  9. width:200px;
  10. height:100px;
  11. padding:10px;
  12. border:30px red solid;
  13. /* 外边距写上以后,自动匹配html根元素还是body元素并没有计算在盒的长度里。 */
  14. /* margin:15px; */
  15. /* 原大小是200*100,加上了边框30和内边10。所以现在的盒是width:200+10+10+30+30=280px height:100+10+10+30+30=180px */
  16. /*如果想要所见即所得大小,就要打开box-sizing: border-box 开关*/
  17. }
  18. </style>
  19. </body>
  20. </html>
  21. ![](https://img.php.cn/upload/image/347/943/953/1676177702257219.jpg)
  22. ![](https://img.php.cn/upload/image/652/645/690/1676177717303798.jpg)
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:最后这两个图片,不要放在代码块里应该就显示出来了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments