CSS文字溢出问题

本文阅读 2 分钟
首页 前端笔记 正文
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <style type="text/css">
  7. /*文字溢出问题*/
  8. .wordNowrap {
  9. width: 50%;
  10. height: 500px;
  11. margin: 0 auto;
  12. background: tan;
  13. }
  14. /*单行溢出···*/
  15. .singleLine {
  16. width: 300px;
  17. height: 50px;
  18. background: teal;
  19. /*单行溢出···*/
  20. overflow: hidden;
  21. text-overflow: ellipsis;
  22. white-space: nowrap;
  23. }
  24. /*多行溢出···*/
  25. .moreLine {
  26. width: 00px;
  27. height: 60px;
  28. line-height: 30px;
  29. /*将height的高度值设置为line-height的值的2倍 以防多出的文字漏出*/
  30. background: paleturquoise;
  31. display: -webkit-box;
  32. overflow: hidden;
  33. -webkit-line-clamp: 2;
  34. -webkit-box-orient: vertical;
  35. }
  36. .moreLine_box{
  37. width: 360px;
  38. height: 60px;
  39. }
  40. /*多行后面···虚化*/
  41. .moreLine_after {
  42. width: 360px;
  43. /*将height的高度值设置为line-height的值的2倍 以防多出的文字漏出*/
  44. height: 60px;
  45. line-height: 30px;
  46. overflow: hidden;
  47. position: relative;
  48. background: #fff;
  49. padding: 30px;
  50. }
  51. .moreLine_after::after {
  52. position: absolute;
  53. content: "...";
  54. bottom: 0;
  55. right: 20px;
  56. background: linear-gradient(left, transparent, #eee 55%);
  57. background: -webkit-linear-gradient(left, transparent, #eee 55%);
  58. background: -moz-repeating-linear-gradient(left, transparent, #eee 55%);
  59. background: -moz-repeating-linear-gradient(left, transparent, #eee 55%);
  60. padding-left: 20px;
  61. }
  62. </style>
  63. </head>
  64. <body>
  65. <div class="wordNowrap">
  66. <h2>文字溢出处理</h2>
  67. <p class="singleLine">单行 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二</p>
  68. <p class="moreLine">
  69. 多行 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二
  70. </p>
  71. <div class="moreLine_box">
  72. <p class="moreLine_after">
  73. 多行末尾虚化 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行末尾虚化 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行末尾虚化 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行末尾虚化 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二 多行末尾虚化 撒旦发所多撒多撒多撒多撒多撒多撒多撒翁翁群翁无群二
  74. </p>
  75. </div>
  76. </div>
  77. </body>
  78. </html>
解压密码: detechn或detechn.com

免责声明

本站所有资源出自互联网收集整理,本站不参与制作,如果侵犯了您的合法权益,请联系本站我们会及时删除。

本站发布资源来源于互联网,可能存在水印或者引流等信息,请用户自行鉴别,做一个有主见和判断力的用户。

本站资源仅供研究、学习交流之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。

PHP时间对比,生成多少分钟(天/月/年)前
« 上一篇 10-08
PHP优惠码生成
下一篇 » 10-10

发表评论