Get the App
SLTechnology News&Howtos  ›  Development  › 

How does css set the maximum width and height of an element

Shulou Source: shulou.com Published: 2022-06-02 07:46:30 09月30日 Update

Editor to share with you how to set the maximum width and height of css elements, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Setting method: 1, use the "max-width" attribute to set the maximum width of the element, the syntax is "element {max-width: the maximum width value of the element;}"; 2, use the "max-height" attribute to set the maximum height of the element, the syntax is "element {max-width: the maximum height value of the element;}".

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

How css sets the maximum width and height of an element

In css, you can use the max-width and max-height attributes to set the maximum width and height of an element, the function of the max-width attribute is to define the maximum width of the element, and the function of the max-height attribute is to set the maximum height of the element.

Let's take a look at how to set the maximum width and height of an element through an example, as follows:

Document p {text-indent: 1cm; max-width:350px; max-height:100px;}

The danger is very high! The westward way is harder than to climb the sky! According to legend, Bombyx mori and Yufu established the kingdom of Shu, and the founding of the country has been impossible to discuss in detail for a long time! Since then, there have been about 48,000 people who have no contact with Qin Sai. In the west of Taibai Mountain, there is a path that birds can cross, which can cross the top of the eyebrow. The five strong men of Shu were crushed to death in the landslide, and the staircase paths of the two places began to connect with each other. There are mountain tops blocking the six dragons of the sun god, and tortuous rivers emptied by surging waves below. The yellow swan, which is good at flying high, can not be flown by, and the ape wants to climb. How the Qingni Ridge twists and turns around the mountains, lingering nine bends around the rocks within a hundred steps. You can touch ginseng and Jing Xing to hold your head and hold your breath, and you can sit down and sigh in horror with your hands.

Output result:

The above is all the content of the article "how to set the maximum width and height of elements in css". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Maximum element width height attribute article function content example grammar at a loss Min Shen Li well the difficulty of Shu Road difficult to go up to the blue sky under there not much people strong men most of them ladder Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Information Linux MySQL macOS