• 多行超高 溢出省略


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>多行超高 溢出省略</title>
    <style type="text/css">
    p{
        100px;
        height:100px;
        border:2px solid red;
        font-size:12px;
        
        }
        
    /*****css方法 适用chrome  和  oper  内核的浏览器***
    .box span{
        display:inline-block;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 7;
    overflow: hidden;
     text-overflow: -o-ellipsis-lastline;
    }    
    ***/
        
    </style>
    </head>
    
    <body>
    <p class="box">
        <span>
            文本内容文本内容文本内容文本内容文本内容文本内容文本内容
            文本内容文本内容文本内容文本内容文本内容文本内容
            文本内容文本内容文本内容文本内容文本内容文本内容
            文本内容文本内容文本内容文本内容文本内容文本内容
        </span>
    </p>
    
    </body>
    <script  type="text/javascript" src="补货页面/js/jquery-1.7.2.min.js"></script>
    
    <script type="text/javascript">
    $(function(){
        $(".box").each(function(i){
            var divH = $(this).height();
            var $p = $("span", $(this)).eq(0);
            while ($p.outerHeight() > divH) {
                $p.text($p.text().replace(/(s)*([a-zA-Z0-9]+|W)(...)?$/, "..."));
            };
        });
        
    })
    </script>
    <!---->
    </html>
  • 相关阅读:
    Tarjan算法
    10JS数组
    9JS循环
    8.JS流程控制
    7.JS运算符
    6.JS方法
    5.JS变量的各种问题
    java封装遇到的问题
    js报Uncaught SyntaxError: Unexpected token <错误 解决方法:
    使用layui出现Uncaught ReferenceError: layui is not defined问题解决:
  • 原文地址:https://www.cnblogs.com/jinsuo/p/6085063.html
Copyright © 2020-2023  润新知