Several Methods for hiding extra text with CSS

Source: Internet
Author: User

Which of the following methods is usually used to offset the font?

(1)
Use text-indent:-9999px;

However, he has a limitation that he only applies to block-level element blocks.
And sometimes we want to offset the font on.
So the question comes.
Text-indent:-9999px; although easy to use
If a is converted into a block, the elements behind him will be pushed to the next line.
If a is followed by a button
Float will be used to float to bring people behind him
Is it a little troublesome?

(2)
Line-Height: 0;
Font-size: 0;
Overflow: hidden;

Can "hide" the font above your background perfectly
Ie6.0, 7.0, 8.0, and Firefox 3.010 passed the test.

(3)
The most convenient thing is to add a span and then display: None, without any bugs.
Unfortunately, when multiple tags are added and used in a loop, a bunch of bytes are added to HTML. We recommend that you use a single button.

However, it is difficult to hide the input value.
So we can only use block and text-indent to "offset" to simulate hiding.
Display: block;
Font-size: 0;
Line-Height: 0;
Text-indent:-9999px;
Ie6.0, 7.0, and Firefox 3.010 passed the test.

(4)

CSS escape contains extra text...

Class = "g_p_center g_t_right g_c_pdin g_h_20 c08" style = "margin-bottom: 15px"> class = "g_p_left" >>< Div style = "width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; Border: 1px solid red "> try hi.baidu.com/commy. For more information, see hi.baidu.com/commy, </div> class = "g_blog_list"> class = "g_t_center g_c_pdin g_p_center c07 content"> class = "ns_content">

Syntax:
Text-overflow: Clip | ellipsis

Parameters:
Clip: do not show the omitted mark (...), but simply crop
(Clip is not commonly used !)
Ellipsis: when the object text overflows, the omission mark (...) is displayed (...)

Note:
Sets or retrieves whether an omission mark (...) is used to indicate text overflow in the object.
Note that the text-overflow: ellipsis attribute has no effect in ff.

Example:
Div {text-overflow: Clip ;}

Text-overflow is a special style. We can use it instead of the title truncation function we usually use, and it is more friendly to search engines. For example, the title file contains 50 Chinese characters, our list may only have a width of PX. If the function is intercepted by the title, the title is incomplete. If we use the CSS style text-overflow: ellipsis, the output title is complete, it is not displayed due to the limitation of the container size.

Related Article

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.