ff文字省略号
2016-05-19 16:07
211 查看
写手机端页面的时候遇到,文字超过两行,多的文字需要省略。
css代码:
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
写这些就好,由于手机端页面无兼容性;用FF的浏览器看到效果的时候,有很大的兼容问题。
百度了一下,发现有用after的写法,无任何兼容问题!服气~
例如:
p {
position:relative;
line-height:1.4em;
/* 3 times the line-height to show 3 lines */
height:4.2em;
overflow:hidden;
}
p::after {
content:"...";
font-weight:bold;
position:absolute;
bottom:0;
right:0;
padding:0 20px 1px 45px;
background:url(http://css88.b0.upaiyun.com/css88/2014/09/ellipsis_bg.png) repeat-y;
}
学习了
css代码:
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
写这些就好,由于手机端页面无兼容性;用FF的浏览器看到效果的时候,有很大的兼容问题。
百度了一下,发现有用after的写法,无任何兼容问题!服气~
跨浏览器兼容的方案
比较靠谱简单的做法就是设置相对定位的容器高度,用包含省略号(…)的元素模拟实现;例如:
p {
position:relative;
line-height:1.4em;
/* 3 times the line-height to show 3 lines */
height:4.2em;
overflow:hidden;
}
p::after {
content:"...";
font-weight:bold;
position:absolute;
bottom:0;
right:0;
padding:0 20px 1px 45px;
background:url(http://css88.b0.upaiyun.com/css88/2014/09/ellipsis_bg.png) repeat-y;
}
学习了
相关文章推荐
- 透视校正插值(Perspective-Correct Interpolation)
- Win7系统启动失败出现错误提示0XC000000F的解决方法
- 常用sql语句记录--sqlserver
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- 软件质量
- openstack-ansible Chapter 4. Deployment configuration
- mac 终端下的命令大全
- 超图对接NSDTF-DEM数据
- python3 使用 protobuf3 序列化踩过的坑
- libxml/tree.h file not found解决办法
- Windows 7下安装使用Sublime Text 3
- Jmeter CSV 参数化/检查点/断言
- 跨机器替bin
- 小技巧:SQL查询
- android 软键盘弹出 自动调整布局
- Android情景分析之深入解析zygote
- 利用runtime查看苹果私有API
- Objective-C实现无限循环轮播器
- Android学习,探究活动
- HashMap的工作原理