CSS Dimension

CSS size

css size (dimension) attribute includes the following aspects

height Set the height of the element.

width Set the width of the element.

max-height Set the maximum height of the element.

max-width Set the maximum width of the element.

min-height Set the minimum height of the element.

min-width Set the minimum width of the element.

line-height Set the line height.

max/min-height/width sets the maximum and minimum height width of the element.

line-height sets the line height, which refers to the top of the first line to the The height of the top of the second row.

Set the height of the element

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title></title> 
<style>
img.normal
{
height:auto;
}
img.big
{
height:120px;
}
p.ex
{
height:100px;
width:100px;
}
</style>
</head>
<body>
<img class="normal" src="http://www.visionunion.com/admin/data/file/img/20140111/20140111004002.jpg" width="95" height="84" /><br>
<img class="big" src="http://www.visionunion.com/admin/data/file/img/20140111/20140111004002.jpg" width="95" height="84" />
<p class="ex">这个段落的高和宽是 100px.</p>
</body>
</html>

Use percentage to set the height of the image

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style>
html {height:100%;}
body {height:100%;}
img.normal {height:auto;}
img.big {height:50%;}
img.small {height:10%;}
</style>
</head>
<body>
<img class="normal" src="http://www.visionunion.com/admin/data/file/img/20140111/20140111004002.jpg" width="95" height="84" /><br>
<img class="big" src="http://www.visionunion.com/admin/data/file/img/20140111/20140111004002.jpg" width="95" height="84" /><br>
<img class="small" src="http://www.visionunion.com/admin/data/file/img/20140111/20140111004002.jpg" width="95" height="84" />
</body>
</html>


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> img.normal { height:auto; } img.big { height:120px; } p.ex { height:100px; width:100px; } </style> </head> <body> <img class="normal" src="http://www.visionunion.com/admin/data/file/img/20140111/20140111004002.jpg" width="95" height="84" /><br> <img class="big" src="http://www.visionunion.com/admin/data/file/img/20140111/20140111004002.jpg" width="95" height="84" /> <p class="ex">这个段落的高和宽是 100px.</p> </body> </html>
submitReset Code