Home > Web Front-end > CSS Tutorial > How to set the text display height and hide the excess part in css

How to set the text display height and hide the excess part in css

WBOY
Release: 2021-12-01 14:59:37
Original
3325 people have browsed it

Method: 1. Use the height attribute to set the display height of the text element. The syntax is "text element {height: height value;}"; 2. Use the overflow attribute to hide the part that exceeds the text height. The syntax is: "Text element {overflow:hidden;}".

How to set the text display height and hide the excess part in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

How to set the display height of text in css and hide the excess part

We can set the display height of text elements through the height attribute and set it through the overflow attribute Text elements are shown and hidden when they exceed their height.

The overflow attribute specifies what happens when content overflows the element box. When the element value is set to hidden, the excess part will be hidden.

The example is as follows:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <style type="text/css">
            div{
                width:200px;
                height:100px;
                border:1px solid black;
                overflow:hidden;
            }
        </style>
    </head>
    <body>
        <div>css设置文本显示高度超出部分隐藏css设置文本显示高度超出部分隐藏css设置文本显示高度超出部分隐藏css设置文本显示高度超出部分隐藏css设置文本显示高度超出部分隐藏css设置文本显示高度超出部分隐藏css设置文本显示高度超出部分隐藏</div>
    </body>
</html>
Copy after login

Output result:

How to set the text display height and hide the excess part in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to set the text display height and hide the excess part in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template