Blogger Information
Blog 9
fans 0
comment 0
visits 5926
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
html字体图标及盒模型练习
不是本人
Original
670 people have browsed it

1.盒模型的布局理解

  • 布局原则:盒模型按照屏幕从左到右,从上到下排列。行内元素可以和行内元素在同一行,块元素要独占一行。

  • 默认排列方式:先左右,后上下。也就是说,一个元素,首先从最顶行,开始排,后面的元素依次排该元素的右边,先写的先排。一行排满之后开始下一行,默认依然是从左往右。遇到块元素会另起一行,左右都不允许有其他元素。

  • 元素类型:盒模型根据display属性,分为block(块元素),inline(行内元素),inlineblock(行内块元素)。

2.box-sizing解决了什么问题?

box-sizing主要是方便布局的时候计算盒模型的尺寸。box-sizing主要有两个属性,一个是content-box,一个是border-box。content-box计算盒子尺寸的时候设定的width和height未包含padding和border,因此盒子实际尺寸,会比设定的大。而border-box计算尺寸的时候,设定的尺寸已经包含了padding和border,因此设定的尺寸,即为盒子实际尺寸。
共同点是,两者都不包含margin。
下图为bordre-box效果
border-box效果

下图为content-box效果
content-box效果

3.在页面中使用字体图标

4.盒模型常用属性


代码如下

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>伪类字体图标盒模型</title>
  8. <link
  9. rel="stylesheet"
  10. href="http://at.alicdn.com/t/font_2646625_atoayy3we5.css"
  11. />
  12. <style>
  13. /* 自定义字体图标大小和颜色 */
  14. .icon-dianzan {
  15. font-size: 30px;
  16. color: crimson;
  17. }
  18. /* 盒模型常用属性演示 */
  19. div {
  20. width: 500px; /*宽度*/
  21. height: 200px; /* 高度 */
  22. border: 1px solid red; /* 边框 */
  23. padding: 3px; /* 内边距 */
  24. margin: 3px; /* 外边距 */
  25. background-color: rgb(167, 252, 233); /* 背景颜色 */
  26. border-radius: 25px; /* 圆角 */
  27. }
  28. .d1 {
  29. box-sizing: border-box; /* 尺寸计算模式 */
  30. }
  31. .d2 {
  32. box-sizing: content-box; /* 尺寸计算模式 */
  33. }
  34. </style>
  35. </head>
  36. <body>
  37. <p>在页面中使用字体图标</p>
  38. <span class="iconfont icon-dianzan"></span>
  39. <br />
  40. <div class="d1"></div>
  41. <div class="d2"></div>
  42. </body>
  43. </html>
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
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!