Blogger Information
Blog 8
fans 1
comment 0
visits 6636
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
盒模型与字体图标使用
JOAblog
Original
673 people have browsed it

盒模型与字体图标使用

字体图标使用

首先登录https://www.iconfont.cn/ 平台,选择我们要用的图片
图片示例:

html代码实现:

  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>Document</title>
  8. <link rel="stylesheet" href="./icon/iconfont.css" />
  9. </head>
  10. <body>
  11. <span class="iconfont icon-zaixiankefu">在线客服</span>
  12. <span class="iconfont icon-mendianliebiao">门店管理</span>
  13. <span class="iconfont icon-woyaofaquan">优惠券</span>
  14. <span class="iconfont icon-shouruguanli">收入金额</span>
  15. </body>
  16. </html>

css代码:

  1. @font-face {
  2. font-family: "iconfont"; /* Project id */
  3. src: url('iconfont.ttf?t=1625204533062') format('truetype');
  4. }
  5. .iconfont {
  6. font-family: "iconfont" !important;
  7. font-size: 16px;
  8. font-style: normal;
  9. -webkit-font-smoothing: antialiased;
  10. -moz-osx-font-smoothing: grayscale;
  11. }
  12. .icon-zaixiankefu:before {
  13. content: "\e76e";
  14. }
  15. .icon-mendianliebiao:before {
  16. content: "\e76f";
  17. }
  18. .icon-woyaofaquan:before {
  19. content: "\e771";
  20. }
  21. .icon-shouruguanli:before {
  22. content: "\e770";
  23. }

理解布局的原则与元素的默认排列方式与元素类型.理解布局的原则与元素的默认排列方式与元素类型.

布局的原则:

  1. 我们的可视化窗口是一个二维空间,所以我们的布局要么是横着要么就是竖着的。

元素的默认排列方式:

  1. 元素默认的排列方式都是以文档流为主由左至右由上之下

元素类型:

  1. 1.块状元素
  2. 块状元素在网页中就是以块的形式显示,所谓块状就是元素显示为矩形区域。
  3. 默认情况下,块状元素都会占据一行,按顺序自上而下排列。
  4. 通俗地说,两个相临的块状元素不会出现并列显示的现象。
  5. 块状元素,还可以定义自己的宽度和高度。
  6. 块状元素,一般都作为其他元素的容器。
  7. 他可以容纳其他内联元素和块状元素。我们可以把这个容器比喻成一个盒子。
  8. 2.内联元素
  9. 内联元素(行内元素)。
  10. 内联元素的表示方式,始终以行内逐个进行显示。
  11. 内联元素没有自己的形状,不能定义自己的宽高。他的宽高要以里面的内容决定。
  12. 内联元素也会遵循盒模型基本原则,但个别属性不能正确显示

盒模型常用属性有哪些

margin外边距
border边框
padding内边距
width
height
图示:

代码实现:

  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. </head>
  9. <style>
  10. body {
  11. margin: auto;
  12. }
  13. body [class="div"] {
  14. width: 100px;
  15. height: 100px;
  16. margin: 100px;
  17. border: solid;
  18. border-color: red;
  19. padding: 50px;
  20. }
  21. </style>
  22. <body>
  23. <div class="div">这里是内容</div>
  24. </body>
  25. </html>

图示: box-sizing属性的解决了什么问题?

box-sizing属性的解决了什么问题?解决了布局的简化和计算的方便
图示(没有使用box-sizing前):

图示(使用box-sizing后):

代码:

  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. </head>
  9. <style>
  10. .box {
  11. width: 150px;
  12. height: 150px;
  13. margin: 15px;
  14. padding: 10px;
  15. border: red solid 5px;
  16. }
  17. .box {
  18. box-sizing: border-box;
  19. }
  20. </style>
  21. <body>
  22. <div class="box">这里是内容</div>
  23. <div class="box">这里是内容2</div>
  24. </body>
  25. </html>
Correcting teacher:天蓬老师天蓬老师

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!