Home >Web Front-end >Front-end Q&A >What is used to set text height in css3

What is used to set text height in css3

WBOY
WBOYOriginal
2022-06-20 15:40:341552browse

In CSS3, you can use the height attribute together with the overflow attribute to set the text height; the height attribute is used to set the height of the element, and the overflow attribute is used to set the text to be hidden beyond the height of the element. The syntax is "text element {height: The height value that needs to be displayed;overflow:hidden;}".

What is used to set text height in css3

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

What is used to set the text height in css3

We can set the display height of the text element through the height attribute, and set the display and hide when the text element exceeds the height through the overflow attribute.

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.

Examples are 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>

Output results:

What is used to set text height in css3

(Learning video sharing: css video tutorial,html video tutorial)

The above is the detailed content of What is used to set text height in css3. For more information, please follow other related articles on the PHP Chinese website!

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