您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jQuery优化文字超过规定字数用户体验

2025/11/28 4:38:26发布29次查看
这次给大家带来jquery优化文字超过规定字数用户体验,jquery优化文字超过规定字数用户体验的注意事项有哪些,下面就是实战案例,一起来看一下。
<!doctype html><html lang="en"><head>  <meta charset="utf-8">  <title>jquery自动添加省略号</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 ph = $(this).height();        var $p = $(p, $(this)).eq(0);        while ($p.outerheight() > ph) {          $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>  <p 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>  </p></body><script></script></html>
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
怎样对邮箱地址格式进行验证
vue的ui组件库自定义动态组件
以上就是jquery优化文字超过规定字数用户体验的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product