文字超过1行、2行或者规定的行数,文字自动加省略号
来源:互联网 发布:新浪微博刷粉软件 编辑:程序博客网 时间:2024/04/28 01:09
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> $(function () { $(".figcaption").each(function (i) { var divH = $(this).height(); var $p = $("p", $(this)).eq(0); while ($p.outerHeight() > divH) { $p.text($p.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "...")); }; }); }); </script> <style> *{ padding: 0px; margin: 0px; } .figcaption{ width: 300px; height: 50px; /*根据父元素的高度来添加省略号 *可以任意设置显示的行数 */ border: 1px solid red; } </style></head><body> <div class="figcaption"> <p> You probably can't do it (currently?) without a fixed-width font like Courier. With a fixed-width font every letter occupies the same horizontal space, so you could probably count the letters and multiply the result with the current font size in ems or exs. Then you would just have to test how many letters fit on one line, and then break it up.</p> </div></body><script></script></html>
阅读全文
0 0
- 文字超过1行、2行或者规定的行数,文字自动加省略号
- 溢出文字自动加省略号
- 文字超过行后隐藏显示省略号
- div文字溢出自动加省略号
- 文字溢出自动加省略号 兼容IE8
- 微信小程序 文字超过行后隐藏显示省略号
- 文字超过多行(自定义行数)就显示省略号
- 文字超长加省略号
- 文字超过div用省略号
- 使用纯CSS实现文字超过一定的长度后自动显示省略号
- 超过长度自动加省略号
- 拖动窗口大小,文字自适应宽度,自动加省略号。
- 超过指定长度的文字用省略号表示
- 限制文本个数,行数,其余的省略号,文字阴影效果
- 多行多余文字省略号
- 文字超过一定字数用省略号显示
- html文字超过部分显示为省略号
- 文字超过div(或者input框等)宽度用省略号显示css
- php spl_autoload_register()函数
- java多线程自我理解01
- C#的异常处理
- CodeForces
- 15位身份证补全为18位身份证算法
- 文字超过1行、2行或者规定的行数,文字自动加省略号
- C#开发微信门户及应用(46)-基于Bootstrap的微信门户应用管理系统功能介绍
- 1.Windows核心编程-基础知识
- POJ 2155 Matrix(二维树状数组+数组数组区间更新+单点查询)
- Java使用jbarcode生成条形码
- CodeForces
- centos7 Qt5.9.1 opencv静态库报grfmt_exr.cpp错误
- select函数(C语言)
- 无法完成请求,因为文件格式模块不能解析,PS新手们是否遇到呢?