CSS text wrapping and ellipsis

Source: Internet
Author: User

CSS text wrapping and ellipsisPosted in 2011/04/22

Some of the relevant properties and W3Schools are referenced below:

The White-space property sets how to handle whitespace within an element.
Http://www.w3schools.com/css/pr_text_white-space.asp
White-space:normal | Nowarp | Pre | Pre-line | Pre-warp | Inherit

Word-warp property setting How to handle a word's wrapping
Http://www.w3schools.com/css3/css3_pr_word-wrap.asp
Word-wrap:normal | Break-word

Word-break property set How to handle word break, only IE is supported
Http://www.w3schools.com/css3/css3_pr_word-break.asp
Word-break:normal | Break-all | Hyphenate

Overflow property setting How to handle content outside of element borders
Http://www.w3schools.com/css/pr_pos_overflow.asp
overflow:visible | Hidden | Scroll | Auto | Inherit

Text-overflow is a relatively special property, for out-of-element border with the ellipsis display in general there is no perfect CSS solution, need help with JavaScript

Text-overflow:clip | ellipsis | Ellipsis-word
Clip: Do not display the ellipsis tag (...). ), but a simple cut
Ellipsis: Displays ellipsis (...) when text inside an object overflows. ), the position where the ellipsis is inserted is the last character.
Ellipsis-word: Displays ellipsis (...) when text inside an object overflows. ), the position of the ellipsis insertion is the last word (word).

Opera-o-text-overflow
Firefox3 not supported can solve this problem with-moz-bing (https://developer.mozilla.org/En/CSS/-moz-binding)

Help
01020304050607080910111213141516171819202122232425262728293031 <title>文字折行与省略号</title><style type="text/css">p.nowarp {      overflow: hidden;      white-space: nowrap;      text-overflow: ellipsis;/*Not working in FF*/}p.warp {      overflow: hidden;      white-space: normal;      word-warp: break-word;      word-break: break-all;/*Only work in IE*/      text-overflow: ellipsis;/*Not working in FF*/}</style></head><body><div style="width: 300px; border: 1px solid red;">      <p class="nowarp">      禁止换行,且用省略号表示超出的部分,哈哈哈哈哈哈哈哈啊哈哈啊哈哈      </p></div><div style="width: 300px; border: 1px solid red;">      <p class="warp">      自动换行,veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylong      </p></div></body>

Display effects under IE and FF

CSS text wrapping and ellipsis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.