Home >Web Front-end >HTML Tutorial >td displays up to 2 lines_html/css_WEB-ITnose

td displays up to 2 lines_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:39:291960browse

The bound data may be less than 2 lines or more than 2 lines. If it is larger than two lines, let the part larger than two lines not be displayed, and only fill the two lines


Reply to the discussion (solution)

in the background Make a judgment and write it. Use the ternary operator rows.count>2 "Display part": display all

and judge and write in the background. Use the ternary operator rows.count>2 "Display part": display all



Ah, I couldn't express myself clearly. It's a problem with the length of the text in one line. The width of that column is set to be fixed. If the text is longer, it will be displayed in more than two lines. Can this be solved with styles? Setting the height of tr does not work.

CSS can solve the problem of automatic line wrapping when the width exceeds word-wrap:break-word; word-break:break-all;
First fix the width and height, and then judge whether the number of words is exceeded based on the number of bytes

Use overflow:hidden; text-overflow:ellipsis; and replace it with ellipses.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn