css 文字展示兩行 其餘的省略符號顯示

來源:互聯網
上載者:User

標籤:doctype   單詞   comment   lips   normal   ace   設定   isp   htm   

 

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Document</title>

</head>

<style>

    .comment_inner{

    width: 200px;

    word-break: break-all;

    text-overflow: ellipsis;

    display: -webkit-box; /** 對象作為伸縮盒子模型顯示 **/

    -webkit-box-orient: vertical; /** 設定或檢索伸縮盒對象的子項目的相片順序 **/

    -webkit-line-clamp: 3; /** 顯示的行數 **/

    overflow: hidden;  /** 隱藏超出的內容 **/

    }   

</style>

<body>

    

     

<div>

   <p>

word-break 屬性規定自動換行的處理方法。normal(使用瀏覽器預設的換行規則。),break-all(允許在單詞內換行。),keep-all(只能在半形空格或連字號處換行。)

   </p>

</div> 

    

</body>

</html>

 

 

一般常用 一行的。

1.overflow:hidden;
2.text-overflow:ellipsis;
3.-o-text-overflow:ellipsis;
4.white-space:nowrap;
5.width:100%;
其中,overflow: hidden和white-space: nowrap都是必須的否則不會顯示省略符號;-o-text-overflow: ellipsis針對Opera;而寬度的設定主要是針對IE6;
該方法支援Internet Explorer, Safari, Chrome 和 Opera,但FF並不支援,不過可以通過Jquery來實作類別似的效果。

css 文字展示兩行 其餘的省略符號顯示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.