Blogger Information
Blog 9
fans 0
comment 7
visits 6020
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Chapter8 背景控制与字体图标
无关
Original
564 people have browsed it

一、背景控制的常用属性

1、背景控制的常用属性表

语法 描述
background-color 设置背景颜色
background-image 设置背景图片
background-repeat 设置背景平铺方向
background-position 设置背景图像的位置
background-size 拉伸背景图片
background-clip 设置背景覆盖范围
background: linear-gradient() 设置背景角度、颜色渐变
box-shadow 设置背景阴影外发光效果
border-radius 设置背景框四个角的弧度

2、背景案例:

3、源码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>背景</title>
  7. <style>
  8. .box{
  9. width: 200px;
  10. height: 200px;
  11. /* border:1px solid #000; */
  12. /* 边角度数 */
  13. border-radius: 100px;
  14. border-radius: 50px;
  15. /* 背景色 */
  16. background-color: lightgreen;
  17. /* 内边距是透明的,只能设置宽度,不能设置样式,故背景色默认可以从内边距透出来 */
  18. /* padding:20px; */
  19. /* 控制背景的覆盖范围,限制在内容区,背景裁切 */
  20. background-clip: border-box;
  21. background-clip: content-box;
  22. /* 渐变 */
  23. /* 从上到下渐变 */
  24. background:linear-gradient(coral,yellow);
  25. /* 控制角度 */
  26. /* 45度, */
  27. background:linear-gradient(45deg,blue,yellow);
  28. background:linear-gradient(to right,blue,yellow);
  29. background:linear-gradient(to right,blue,red,orange,pink,yellow);
  30. background:linear-gradient(
  31. to right,
  32. rgba(255,0,0,0.7),
  33. blue,
  34. red,
  35. orange,
  36. pink,
  37. yellow);
  38. /* background-clip: content-box; */
  39. /* 背景图片 */
  40. background-image:url('girl.png') ;
  41. background-repeat:no-repeat;
  42. /* background-repeat:repeat-x;
  43. background-repeat:repeat-y;
  44. background-attachment: fixed; */
  45. /* 背景定位:位置; */
  46. /* background-position:50px 60px ; */
  47. /* background-position:right center ; */
  48. /* 上下两行相等 */
  49. /* background-position: center right; */
  50. /* 只写一个,第二个默认是center */
  51. /* background-position: left ; */
  52. /* background-position: 50% 20% ; */
  53. /* 只写一个,第二个默认是50% */
  54. /* background-position: 50% ; */
  55. /* background-size :contain;
  56. background-size :cover; */
  57. /* 简写 */
  58. background:violet;
  59. background:violet url("girl.png") no-repeat center;
  60. position: relative;
  61. top:20px;
  62. left:30px ;
  63. /* box-shadow: 5px-水平偏移, 8px-垂直偏移, 10px-扩散度, black; */
  64. box-shadow: 15px 8px 10px blue;
  65. }
  66. /* 鼠标悬停样式hover{} */
  67. /* 鼠标移到后变成手形:cursor:pointer; */
  68. .box:hover{
  69. /* 外发光 */
  70. box-shadow: 0 0 40px red;
  71. cursor:pointer;
  72. }
  73. </style>
  74. </head>
  75. <body>
  76. <div class="box">
  77. </div>
  78. </body>
  79. </html>

二、精灵图的原理与实现

1、精灵图


2、源码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>背景实战:精灵图/雪碧图</title>
  7. <style>
  8. .box1{
  9. width:600px;
  10. height: 600px;
  11. /* padding-left:0 ; */
  12. border: 1px solid red;
  13. background-image: url("01.png");
  14. background-repeat: no-repeat;
  15. background-position: 20px 30px ;
  16. background-color:lightgreen ;
  17. }
  18. .box2{
  19. width: 90px;
  20. height: 90px;
  21. background-image: url("01.png") ;
  22. background-position: -180px -90px;
  23. }
  24. .box3{
  25. width: 90px;
  26. height: 90px;
  27. background-image: url("01.png") ;
  28. background-position: -0px -180px;
  29. }
  30. .box4{
  31. width: 90px;
  32. height: 90px;
  33. background-image: url("01.png") ;
  34. background-position: -270px -360px;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div class="box1"></div>
  40. <div class="box2"></div>
  41. <div class="box3"></div>
  42. <div class="box4"></div>
  43. </body>
  44. </html>

三、阿里图标的引用

1、图例

2、源码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <!-- 引入字体图标的类样式 -->
  7. <link rel="stylesheet" href="font2/iconfont.css"/>
  8. <title>阿里字体图标的使用方法1</title>
  9. <style>
  10. .lf{
  11. font-size: 40px;
  12. color:magenta;
  13. box-shadow: 4px 4px 4px 0;
  14. }
  15. .zg{
  16. font-size: 40px;
  17. color:green;
  18. box-shadow: 4px 4px 4px 0;
  19. }
  20. p{
  21. font-size: 1.2rem;
  22. color:blue;
  23. background-color: lightgreen;
  24. width: 100px;
  25. }
  26. .open-eye{
  27. font-size: 30px;
  28. color: blue;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div>
  34. <span class="iconfont icon-kehulaifang lf"> </span>
  35. <text> 客户来访</text>
  36. <hr>
  37. <span class="iconfont icon-zhuangangguanli zg"></span>
  38. <p>转岗管理 </p>
  39. <span class="iconfont open-eye"> &#xe79c;</span>
  40. </div>
  41. </body>
  42. </html>
Correcting teacher:GuanhuiGuanhui

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