In CSS, you can use the height attribute to set the div height. You only need to add the "height: height value;" style to the div element. The height attribute sets the height of an element, which defines the height of the element's content area, excluding padding, borders, or margins.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css sets div height
In css, you can use the height attribute to set the div height. Code example:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> div { width: 500px; border: 1px solid red; margin: 10px 0; } div.height{ height:100px; } </style> </head> <body> <div> 这是一些文本。 这是一些文本。 这是一些文本。 (默认高度) </div> <div class="height"> 这是一些文本。 这是一些文本。 这是一些文本。(高度设置为100px) </div> </body> </html>
Rendering:
##Description:
The height attribute sets the element's high. Note: The height attribute does not include padding, borders, or margins! Attribute value:Description | |
---|---|
default. The browser will calculate the actual height. | |
length | Use px, cm and other units to define the height.|
% | Based on the percentage height of the block-level object that contains it.
Introduction to Programming! !
The above is the detailed content of How to set div height in css. For more information, please follow other related articles on the PHP Chinese website!