当前位置:   article > 正文

30个html+CSS和html5动画经典案例_html和css简单例子

html和css简单例子

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. <style type="text/css">
  9. * {
  10. margin: 0px;
  11. padding: 0px;
  12. }
  13. .product {
  14. width: 268px;
  15. border-radius: 3px;
  16. border: 5px solid #ddd;
  17. margin: 50px auto 0px;
  18. text-align: center;
  19. }
  20. .product p.describle{
  21. color: #845f3f;
  22. font-size: 16px;
  23. }
  24. .text{
  25. height: 100px;
  26. border-radius: 5px;
  27. background-color: #f8f8f8;
  28. }
  29. a{
  30. text-decoration: none;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div class="product">
  36. <div class="pic">
  37. <img src="12.png" alt="图片"width="150px"height="200px "style="margin-top: 5px; margin-bottom: 20px;"
  38. />
  39. <p class="describle" style="margin-bottom:25px;">快速煮水,安心使用</p>
  40. </div>
  41. <div class="text">
  42. <!-- 通过设置buttons属性中的font-size为0px可设置按钮亦或是图片不留间隙 -->
  43. <div class="buttons" style="padding-top: 10px;">
  44. <!-- cursor:pointer;是css属性设置鼠标翻上去变成手 -->
  45. <a href="https://www.baidu.com/"><button type="button" style="cursor:pointer; background-color:#D64187; color: white; border-radius: 3px; border: transparent; width: 50px;">直播中</button></a>
  46. <a href="https://www.baidu.com/"><button type="button" style="cursor:pointer; color: red;background-color: white; border: #845f3f solid 1px; border-radius: 3px;">特惠</button></a>
  47. <a href="https://www.baidu.com/"><button type="button" style="cursor:pointer; color: aquamarine; border: aquamarine solid 1px; border-radius: 3px; background-color:white;">30天保健价</button></a>
  48. <a href="https://www.baidu.com/"><button type="button" style="cursor:pointer; color: aquamarine; border: aquamarine solid 1px; border-radius: 3px; background-color: white;">售后免邮</button></a>
  49. </div>
  50. <h3>云米电水壶</h3>
  51. <p style="color: red;">¥59</p>
  52. </div>
  53. </div>
  54. </body>
  55. </html>

需要注意的地方:

1.设置块间距如图片 按钮等

  

 <!-- 通过设置buttons属性中的font-size为0px可设置按钮亦或是图片不留间隙 -->

 2.边框三要素颜色、线条类型、线条像素值缺一不可.否则边框无法显示。

color: white; border-radius: 3px;

运行效果如图所示:

 试用场景:淘宝商品展示。橱窗展示。

5.html+css实战小案例,CSS小米商城首页侧边导航栏效果

代码部分:

  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. <style type="text/css">
  9. * {
  10. margin: 0px;
  11. padding: 0px;
  12. }
  13. ul{
  14. list-style: none;
  15. }
  16. a{
  17. text-decoration: none;
  18. }
  19. .all {
  20. position: absolute;
  21. width: 100%;
  22. height: 100%;
  23. background-image: linear-gradient(to right, #fdb787, #c6ffdd);
  24. }
  25. .menu {
  26. width: 300px;
  27. background-color: rgba(255, 255, 255, 0.5);
  28. margin: 50px auto 0px; /*上 左右 下*/
  29. }
  30. .menu ul{
  31. padding: 20px 0px;
  32. }
  33. .menu ul li{
  34. height: 42px;
  35. /* 垂直居中 */
  36. line-height: 42px;
  37. }
  38. .menu ul li a{
  39. /* 设置块元素,目的是为了让a标签占据整行 */
  40. display: block;
  41. /* 文字首行缩进2个字 加字 */
  42. text-indent: 2em;
  43. background-image: url('5箭头.png');
  44. background-repeat: no-repeat;
  45. background-position: 255px;
  46. }
  47. .menu ul li a:hover{
  48. /* 设置块元素,目的是为了让a标签占据整行 */
  49. background-color: #ff6700;
  50. display: block;
  51. /* 文字首行缩进2个字 加字 */
  52. text-indent: 2em;
  53. background-image: url('5箭头.png');
  54. background-repeat: no-repeat;
  55. background-position: 255px;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <!-- 包裹整体所有代码包裹在这里面. -->
  61. <div class="all">
  62. <div class="menu">
  63. <ul>
  64. <li><a href="https://www.baidu.com/" target="blank">手机</a></li>
  65. <li><a href="https://www.baidu.com/" target="blank">电视</a></li>
  66. <li><a href="https://www.baidu.com/" target="blank">笔记本 平板</a></li>
  67. <li><a href="https://www.baidu.com/" target="blank">家电</a></li>
  68. <li><a href="https://www.baidu.com/" target="blank">出行 穿戴</a></li>
  69. <li><a href="https://www.baidu.com/" target="blank">智能路由器</a></li>
  70. <li><a href="https://www.baidu.com/" target="blank">电源 配件</a></li>
  71. <li><a href="https://www.baidu.com/" target="blank">健康 儿童</a></li>
  72. <li><a href="https://www.baidu.com/" target="blank">耳机 音响</a></li>
  73. <li><a href="https://www.baidu.com/" target="blank">生活 箱包</a></li>
  74. </ul>
  75. </div>
  76. </div>
  77. </body>
  78. </html>

需要注意的地方:

  1. .menu ul li a{
  2. /* 设置块元素,目的是为了让a标签占据整行 */
  3. display: block;
  4. /* 文字首行缩进2个字 加字 */
  5. text-indent: 2em;
  6. background-image: url('5箭头.png');
  7. background-repeat: no-repeat;
  8. background-position: 255px;
  9. }

运行效果

 应用场景;左侧菜单,二级菜单导航栏下拉列表

6.第五节:html+css实战小案例,不定向水平居中解决方案开发精美分页效果

代码部分

  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. <style type="text/css">
  9. *{
  10. padding: 0px;
  11. margin: 0px;
  12. }
  13. .foot{
  14. margin-top: 20px;
  15. width: 100%;
  16. height: 200px;
  17. background-color: aquamarine;
  18. text-align: center;
  19. font-size: 0px;
  20. padding: 100px 0px;
  21. }
  22. .foot a{
  23. border: 1px solid #ddd;
  24. background-color: #fff;
  25. display: inline-block;
  26. padding: 0px 10px;
  27. height: 30px;
  28. text-decoration: none;
  29. line-height: 30px;
  30. color: #333;
  31. font-size: 14px;
  32. margin: 0px 2px;
  33. }
  34. </style>
  35. </head>
  36. <body>
  37. <div class="all">
  38. <div class="foot">
  39. <a href="">&lt;</a><a href="">1</a>
  40. <a href="">2</a>
  41. <a href="">3</a>
  42. <a href="">4</a>
  43. <a href="">5</a>
  44. <a href="">...</a>
  45. <a href="">100</a>
  46. <a href="">&gt;</a>
  47. </div>
  48. <div class="foot"></div>
  49. <div class="foot"></div>
  50. </div>
  51. </body>
  52. </html>

运行效果:

 需要注意的地方:

 在编译过程中浏览器会默认把回车空格进行编译

解决办法:

应用场景:进行分页设置 

7.CSS打造精美选项卡菜单效果

代码部分:

  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>css打造精美选项卡</title>
  8. <style type="text/css">
  9. body{
  10. margin: 0px;
  11. }
  12. .tab{
  13. width: 800px;
  14. background-color: #f7f7f7;
  15. border-radius: 50px;
  16. margin: 50px auto 0px;
  17. font-size: 0px;
  18. padding: 5px 0px;
  19. }
  20. .tab span{
  21. border-radius: 25px;
  22. height: 40px;
  23. display: inline-block;
  24. padding: 0px 40px;
  25. line-height: 40px;
  26. font-size: 16px;
  27. }
  28. .tab span i{
  29. width: 26px;
  30. height: 25px;
  31. display: inline-block;
  32. background-image: url('7css精美选项卡icon.png');
  33. /* 只针对行内块级元素有效 */
  34. vertical-align: middle;
  35. margin-right: 5px;
  36. }
  37. .icon2{
  38. background-position: -26px 0px;
  39. }
  40. .icon3{
  41. background-position: -52px 0px;
  42. }
  43. .icon4{
  44. background-position: -78px 0px;
  45. }
  46. .icon5{
  47. background-position: -104px 0px;
  48. }
  49. .icon7{
  50. background-position: -26px 25px;
  51. }
  52. .icon2{
  53. background-position: -26px 0px;
  54. }
  55. .icon3{
  56. background-position: -52px 0px;
  57. }
  58. .icon4{
  59. background-position: -78px 0px;
  60. }
  61. .icon5{
  62. background-position: -104px 0px;
  63. }
  64. </style>
  65. </head>
  66. <body>
  67. <div class="tab">
  68. <span class="current" ><i class="icon1"></i>备孕期间</span>
  69. <span class="current"><i class="icon2"></i>怀孕</span>
  70. <span class="current"><i class="icon3"></i>0-1岁</span>
  71. <span class="current"><i class="icon4"></i>1-2岁</span>
  72. <span class="current"><i class="icon5"></i>2-3岁</span>
  73. </div>
  74. <div class="tab">
  75. <span class="current" style="background-color: pink;"><i class="icon7"></i>备孕期间</span>
  76. <span class="current"><i class="icon8"></i>怀孕</span>
  77. <span class="current" ><i class="icon9"></i>0-1岁</span>
  78. <span class="current"><i class="icon10"></i>1-2岁</span>
  79. <span class="current"><i class="icon11"></i>2-3岁</span>
  80. </div>
  81. </body>
  82. </html>

运行结果

需要注意的地方:

涉及到了

 

 CSS精灵图技术就是把每一个需要用到的图放到一个里面

尽量使用类选择器

8.前端必会的三种CSS网页布局技术

代码部分

  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. <style type="text/css">
  9. *{
  10. margin: 0px;
  11. padding: 0px;
  12. }
  13. .all{
  14. position: relative;
  15. width: 100%;
  16. height: 100%;
  17. background-color: antiquewhite;
  18. }
  19. .container{
  20. width: 1000px;
  21. height: 1500px;
  22. border: 2px solid black;
  23. margin: 0px auto 0px;
  24. }
  25. .column2{
  26. border: 2px solid black;
  27. }
  28. .column2-1{
  29. width: 700px;
  30. height: 300px;
  31. background-color: red;
  32. float: left;
  33. }
  34. .column2-2{
  35. width: 280px;
  36. height: 300px;
  37. background-color: yellow;
  38. float: right;
  39. }
  40. .clear{
  41. clear: both;
  42. /* 清楚左右浮动 */
  43. }
  44. .column3{
  45. margin-top: 20px;
  46. margin-bottom: 20px;
  47. border: 2px solid blue;
  48. }
  49. .column3-1{
  50. width: 200px;
  51. height: 300px;
  52. background-color: aqua;
  53. float: left;
  54. }
  55. .column3-2{
  56. width: 400px;
  57. height: 300px;
  58. background-color: coral;
  59. float: left;
  60. margin: 0px 10px;
  61. }
  62. .column3-3{
  63. width: 360px;
  64. height: 300px;
  65. background-color: blueviolet;
  66. float: right;
  67. }
  68. .clear{
  69. clear: both;
  70. /* 清楚左右浮动 */
  71. }
  72. .column-n ul{
  73. list-style: none;
  74. }
  75. .column-n ul li{
  76. background-color: aquamarine;
  77. width: 190px;
  78. height: 200px;
  79. float: left;
  80. margin: 5px;
  81. }
  82. </style>
  83. </head>
  84. <body>
  85. <div class="all">
  86. <div class="container" >
  87. <div class="column2">
  88. <div class="column2-1"></div>
  89. <div class="column2-2"></div>
  90. <div class="clear"></div>
  91. </div>
  92. <!-- 三列 -->
  93. <div class="column3 clearfix">
  94. <div class="column3-1"></div>
  95. <div class="column3-2"></div>
  96. <div class="column3-3"></div>
  97. <div class="clear"></div>
  98. </div>
  99. <div class="column-n">
  100. <ul>
  101. <li></li>
  102. <li></li>
  103. <li></li>
  104. <li></li>
  105. <li></li>
  106. <li></li>
  107. <li></li>
  108. <li></li>
  109. <li></li>
  110. <li></li>
  111. </ul>
  112. </div>
  113. </div>
  114. </div>
  115. </body>
  116. </html>

这个布局格式需要基本掌握

9. 酷狗音乐热榜效果

代码部分:

  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. <style type="text/css">
  9. body,h3,h4,p{
  10. margin: 0px;
  11. padding: 0px;
  12. }
  13. a{
  14. text-decoration: none;
  15. }
  16. .music-hot{
  17. width: 350px;
  18. height: 500px;
  19. margin: 50px auto 0px;
  20. }
  21. .music-hot h3{
  22. font-weight: 100;
  23. height: 40px;
  24. line-height: 40px;
  25. }
  26. .music-hot h3 span{
  27. font-size: 28px;
  28. }
  29. .music-hot h3 span i{
  30. color: #00a7f6;
  31. font-style: normal
  32. }
  33. .music-hot h3 a{
  34. font-size: 16px;
  35. color: #9c9e9c;
  36. float: right;
  37. }
  38. .music-hot .item{
  39. height: 98px;
  40. background-color: #f6f6f6;
  41. margin-top: 20px;
  42. }
  43. .music-hot .item .item-img{
  44. width: 98px;
  45. height: 98px;
  46. background-color: #00a7f6;
  47. float: left;
  48. }
  49. .music-hot .item .item-text{
  50. width: 232px;
  51. height: 98px;
  52. float: right;
  53. background: url(../img/9-1.png) no-repeat right center;
  54. }
  55. img{
  56. width: 98px;
  57. height: 98px;
  58. }
  59. .music-hot .item .item-text h4{
  60. font-size: 16px;
  61. padding: 8px 0px;
  62. }
  63. .music-hot .item .item-text p{
  64. font-size: 14px;
  65. color: #555;
  66. line-height: 25px;
  67. }
  68. .music-hot .item .item-text p a{
  69. color: #555;
  70. }
  71. .music-hot .item .item-text p a:hover{
  72. color: #ff627f;
  73. }
  74. .music-hot .item .item-text p a:hover span{
  75. color: #ff627f;
  76. }
  77. .music-hot .item .item-text p span{
  78. color: #9999;
  79. }
  80. </style>
  81. </head>
  82. <body>
  83. <div class="music-hot">
  84. <h3><a href="">更多</a><span><i>热门</i>榜单</span></h3>
  85. <div class="item">
  86. <div class="item-img">
  87. <img src="..\img\9-2.jpg" alt="飙升榜">
  88. </div>
  89. <div class="item-text">
  90. <h4>酷狗音乐飙升榜</h4>
  91. <p><a href="">1.很受伤(Live)- <span>郁可唯</span></a></p>
  92. <p><a href="">2.Lemon(柠檬)- <span>米津玄师</a></span></p>
  93. </div>
  94. </div>
  95. <div class="item">
  96. <div class="item-img">
  97. <img src="..\img\9-3.jpg" alt="">
  98. </div>
  99. <div class="item-text">
  100. <h4>酷狗音乐飙升榜</h4>
  101. <p><a href="">1.很受伤(Live)- <span>郁可唯</span></a></p>
  102. <p><a href="">2.Lemon(柠檬)- <span>米津玄师</a></span></p>
  103. </div>
  104. </div>
  105. <div class="item">
  106. <div class="item-img">
  107. <img src="..\img\9-4.jpg" alt="">
  108. </div>
  109. <div class="item-text">
  110. <h4>酷狗音乐飙升榜</h4>
  111. <p><a href="">1.很受伤(Live)- <span>郁可唯</span></a></p>
  112. <p><a href="">2.Lemon(柠檬)- <span>米津玄师</a></span></p>
  113. </div>
  114. </div>
  115. </div>
  116. </body>
  117. </html>

 运行效果:

 注意的地方:绝对路径的设置

关于url()和 src路径

 这两处需要注意一下。

 应用场景 :热门导航 热门列表项

10.CSS开发小米商城产品栏目展示效果

 代码部分:

  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. <style type="text/css">
  9. ul{
  10. margin: 0px;
  11. padding: 0px;
  12. list-style: none;
  13. }
  14. body{
  15. margin: 0px;
  16. padding: 0px;
  17. background-color: #ddd;
  18. }
  19. h4,h3,p{
  20. padding: 0px;
  21. margin: 0px;
  22. }
  23. a{
  24. text-decoration: none;
  25. color: #000;
  26. }
  27. .product{
  28. width: 1226px;
  29. /* height: 700px; */
  30. margin: 50px auto 0px;
  31. }
  32. .product .product-hot{
  33. width: 234px;
  34. /* height: 614px; */
  35. background-color: aquamarine;
  36. float: left;
  37. }
  38. .product .product-hot img{
  39. display: block;
  40. }
  41. .product .product-list{
  42. width: 992px;
  43. /* height: 614px; */
  44. float: right;
  45. }
  46. .clearfix::after{
  47. content: "";
  48. display: block;
  49. clear: both;
  50. }
  51. .product-list ul li{
  52. width: 234px;
  53. height: 300px;
  54. float: left;
  55. margin-left:14px ;
  56. margin-bottom:14px ;
  57. background-color: #fff;
  58. }
  59. .product-list ul li a{
  60. display: block;
  61. height: inherit;
  62. text-align: center;
  63. padding-top: 30px;
  64. /* 怪异盒子模型 宽高+上内外边距 */
  65. box-sizing: border-box;
  66. }
  67. .product-list ul li:nth-last-child(1){
  68. height: 143px;
  69. }
  70. .product-list ul li:nth-last-child(2){
  71. height: 143px;
  72. }
  73. .product-list ul li a img{
  74. width: 160px;
  75. }
  76. .product-list ul li a h3{
  77. font-size: 14px;
  78. font-weight: 400;
  79. padding: 0px 5px 0px;
  80. /* 文字不要换行 y1行显示*/
  81. white-space: nowrap;
  82. /* 超出的部分隐藏 */
  83. text-overflow: ellipsis;
  84. overflow:hidden;
  85. }
  86. .product-list ul li a .desc{
  87. font-size: 14px;
  88. color: #999;
  89. }
  90. .product-list ul li a p.price{
  91. padding-top: 15px;
  92. }
  93. .product-list ul li a p.price span{
  94. font-size: 14px;
  95. color: orange;
  96. margin-right: 10px;
  97. }
  98. .product-list ul li a p.price del{
  99. font-size: 14px;
  100. color: #999;
  101. }
  102. .product-list ul li .txt{
  103. width: 100px;
  104. /* background-color: blue; */
  105. float: left;
  106. margin-left: 20px;
  107. }
  108. .product-list ul li .img{
  109. width: 80px;
  110. height: 80px;
  111. float: right;
  112. margin-right: 20px;
  113. }
  114. .product-list ul li .txt h4{
  115. font-size:14px ;
  116. font-weight: 400;
  117. text-align: left;
  118. }
  119. .product-list ul li .txt p{
  120. margin-top: 15px;
  121. font-size:14px;
  122. text-align: left;
  123. color: orange;
  124. }
  125. .product-list ul li .more{
  126. margin-top: 20px;
  127. }
  128. .product-list ul li .txt h4.ti{
  129. padding-top: 20px;
  130. font-size: 20px;
  131. }
  132. .product-list ul li .txt p.hot{
  133. color: #999;
  134. }
  135. </style>
  136. </head>
  137. <body>
  138. <div class="product clearfix">
  139. <div class="product-hot">
  140. <!-- img标签是一个行内块级元素,默认有空隙 -->
  141. <!-- 导致插入的图片产生空隙,需要转换为行块级元素 -->
  142. <a href=""><img src="../img/mi00.webp" style="width: 234px;" alt=""></a>
  143. </div>
  144. <div class="product-list">
  145. <ul class=" clearfix">
  146. <li><a href="#"><img src="../img/mi01.webp" alt="">
  147. <h3>Xiaomi Watch S1</h3>
  148. <p class="desc">腕事俱备</p>
  149. <p class="price"><span>1099元起</span> <del>2099元起</del></p>
  150. </a>
  151. </li>
  152. <li><a href="#"><img src="../img/mi02.webp" alt="">
  153. <h3>Xiaomi Watch S1</h3>
  154. <p class="desc">腕事俱备</p>
  155. <p class="price"><span>1099元起</span> <del>2099元起</del></p>
  156. </a>
  157. </li>
  158. <li><a href="#"><img src="../img/mi03.webp" alt="">
  159. <h3>Xiaomi Watch S1</h3>
  160. <p class="desc">腕事俱备</p>
  161. <p class="price"><span>1099元起</span> <del>2099元起</del></p>
  162. </a>
  163. </li>
  164. <li><a href="#"><img src="../img/mi04.webp" alt="">
  165. <h3>Xiaomi Watch S1</h3>
  166. <p class="desc">腕事俱备</p>
  167. <p class="price"><span>1099元起</span> <del>2099元起</del></p>
  168. </a>
  169. </li>
  170. <li><a href="#"><img src="../img/mi05.webp" alt="">
  171. <h3>Xiaomi Watch S1</h3>
  172. <p class="desc">腕事俱备</p>
  173. <p class="price"><span>1099元起</span> <del>2099元起</del></p>
  174. </a>
  175. </li>
  176. <li><a href="#"><img src="../img/mi06.webp" alt="">
  177. <h3>Xiaomi Watch S1</h3>
  178. <p class="desc">腕事俱备</p>
  179. <p class="price"><span>1099元起</span> <del>2099元起</del></p>
  180. </a>
  181. </li>
  182. <li><a href="#"><img src="../img/mi07.webp" alt="">
  183. <h3>Xiaomi Watch S1</h3>
  184. <p class="desc">腕事俱备</p>
  185. <p class="price"><span>1099元起</span> <del>2099元起</del></p>
  186. </a>
  187. </li>
  188. <!-- 9/10 -->
  189. <li><a href="#">
  190. <div class="txt">
  191. <h4>Redmi Bus 青春旗舰版</h4>
  192. <p>999元</p>
  193. </div>
  194. <div class="img"><img src="../img/mi08.webp" style="width: 80px;" alt=""></div>
  195. </a></li>
  196. <li><a href="#">
  197. <div class="txt">
  198. <h4 class="ti">浏览更多</h4>
  199. <p class="hot">热门</p>
  200. </div>
  201. <div class="img more"><img src="../img/circle-arrow.svg" style="width: 48px;" alt=""></div>
  202. </a></li>
  203. </ul>
  204. </div>
  205. </div>
  206. </body>
  207. </html>

需要注意的地方:

提到了怪异盒子模型:box-sizing: border-box;这样设置可以使得原本

实际高度变为border的设置高度

此外

 /* 文字不要换行 y1行显示*/

            white-space: nowrap;

            /* 超出的部分隐藏 */

            text-overflow: ellipsis;

            overflow:hidden;

img是行内块级元素,默认格式存在空隙,导致插入的图片有空隙,需要转换为块级元素

运行效果

 

 应用场景,列表项,分栏,图片的设置

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/167124
推荐阅读
相关标签
  

闽ICP备14008679号