多行文本溢出顯示省略符號(…)全攻略

來源:互聯網
上載者:User

標籤:

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />

<meta name="author" content="www.frebsite.nl" />

<title></title>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>

<script type="text/javascript" language="javascript" src="src/js/jquery.dotdotdot.js"></script> <!--jQuery外掛程式-jQuery.dotdotdot-->

jQuery外掛程式-jQuery.dotdotdot



/*firfox下js實現該效果顯示的行數由文本容器的height決定*/

<script type="text/javascript" language="javascript">

$(function() {

$(‘#dot1‘).dotdotdot();

});

</script>

<style type="text/css">

  #dot1{

     width: 200px;

     height: 100px;

}

/*移動web端和chrome瀏覽器下代碼可以直接寫出效果但是firfox下不支援*/

 #dot1{

    display:-webkit-box;

    overflow:hidden;

    text-overflow:ellipsis;

    word-break:break-all;

    -webkit-box-orient:vertical;

    -webkit-line-clamp:2;

}


 </style>

</head>

<body>

<div id="dot1">

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry‘s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</div>

</div>

</body>

</html>

當設定文本超出隱藏後,當我們不設定任何字型時chrome瀏覽器下省略符號顯示在文本最後的上方,只有當我們設定字型為微軟雅黑和一些別的字型時省略符號才會在下方,宋體會顯示在上方。firfox瀏覽器下單行文本省略顯示正常。


多行文本溢出顯示省略符號(…)全攻略

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.