PHP速学视频免费教程(入门到精通)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
这篇文章主要介绍了jquery实现文字超过1行、2行或规定的行数时自动加省略号的方法,涉及jquery针对页面元素属性动态操作相关实现技巧,需要的朋友可以参考下
本文实例讲述了jQuery实现文字超过1行、2行或规定的行数时自动加省略号的方法。分享给大家供大家参考,具体如下:
nbsp;html> <meta> <title>www.jb51.net jQuery自动添加省略号</title> <script></script> <script> $(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> <p> </p><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> <script> </script>
运行效果:
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
已抢7051个
抢已抢93906个
抢已抢14681个
抢已抢51581个
抢已抢193368个
抢已抢86947个
抢