<style>
.div1 {
width: 200px;
height: 200px;
background: red url(img/user.png) no-repeat;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.div1:hover {
overflow: visible;
text-overflow: inherit;
} </style>
 <div class="div1">
qwe Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae voluptatem sapiente fuga facere molestias numquam officiis beatae ex sit atque aspernatur quisquam commodi ratione perspiciatis ducimus dolor minima itaque obcaecati!
</div>

CSS实现单行、多行文本溢出显示省略号

方法一:只显示3行,在第三行结尾显示...

 p{display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: ;
overflow: hidden;
}

方法二:适用性更广,未超出部分也会出现...

 p{
position: relative;
line-height: 20px;
max-height: 40px; /*是行高的整数倍,防止下行文字露出*/
overflow: hidden;
} p::after{
content: "..."; position: absolute; bottom: ; right: ; padding-left: 40px;
background: -webkit-linear-gradient(left, transparent, #fff %);
background: -o-linear-gradient(right, transparent, #fff %);
background: -moz-linear-gradient(right, transparent, #fff %);
background: linear-gradient(to right, transparent, #fff %);
}

最新文章

  1. sql复制表、拷贝表、临时表
  2. QT基本使用
  3. 八大Webkit内核浏览器
  4. 【mysql】【分组】后取每组的top2
  5. 每天进步一点点--&amp;gt;功能fseek() 使用方法
  6. 讨论IT选定的技术招聘企业几点
  7. Cow Uncle 学习了叉积的一点运用,叉积真的不错
  8. myeclipse自动保存修改代码
  9. Version 1.7.0_80 of the JVM is not suitable for this product.Version: 1.8 or greater is required.
  10. 如何让shell脚本自杀
  11. LeetCode &amp; Q35-Search Insert Position-Easy
  12. 在VUE-CLI 3下的第一个Element-ui项目(菜鸟专用)
  13. day11(python)装饰器
  14. MySQL双主+keeplived安装部署说明
  15. Spring Boot 起步
  16. InnoDB 与 MYISAM的区别和联系
  17. SpringBoot(4) SpringBoot热部署
  18. Web、OAuth2/SSO相关拾遗
  19. greys java在线诊断工具
  20. python 回溯法 子集树模板 系列 —— 13、最佳作业调度问题

热门文章

  1. Vue 超快速学习
  2. JS弹出对话框的三种方式
  3. opencv -python
  4. [Day2]变量、数据类型转换以及运算符
  5. [archlinux] 迁移T7从T460s到T470
  6. cocos2dx 粒子系统
  7. ios 10 新特性
  8. 兼容ie10及以上css3加载进度动画
  9. The iOS Simulator deployment target is set to 6.0
  10. OC仿支付宝输入UITextField输入车牌号