How to set element height to 20px in css

青灯夜游
Release: 2023-01-04 09:34:30
Original
3313 people have browsed it

In CSS, you can use the height attribute to set the height of an element. You only need to add the "height:20px;" style to the element to set the height of the element to "20px". The height attribute is used to set the height of the element. This attribute defines the height of the element's content area. Inline non-replaced elements will ignore this attribute.

How to set element height to 20px in css

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

css set the element height to 20px

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<style>
			img.normal {
				height: auto;
			}
			
			img.big {
				height: 120px;
			}
			
			p {
				border: 1px solid red;
			}
			
			p.ex {
				height: 250px;
				width: 250px;
			}
		</style>
	</head>

	<body>
		<img  class="normal" src="img/1.jpg"    style="max-width:90%"  style="max-width:90%" / alt="How to set element height to 20px in css" ><br>
		<img  class="big" src="img/1.jpg"    style="max-width:90%"  style="max-width:90%" / alt="How to set element height to 20px in css" >
		<p>默认宽度和高度。这是段落中的一些文本。这是段落中的一些文本。 这是段落中的一些文本。</p>
		<p class="ex">段落的高和宽是 250px。这是段落中的一些文本。这是段落中的一些文本。这是段落中的一些文本。</p>
	</body>

</html>
Copy after login

Rendering:

How to set element height to 20px in css

(Learning video sharing: css video tutorial)

css height attribute

The height attribute sets the height of the element. The default value is auto and there is no inheritance.

The height attribute defines the height of the element's content area. Pads, borders, and margins can be added outside the content area.

Inline non-replaced elements will ignore this attribute.

Attribute value of the height attribute:

Value Description
auto 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.
inherit Specifies that the value of the height attribute should be inherited from the parent element.

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of How to set element height to 20px in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!