CSS 尺寸 (Dimension) 属性允许你控制元素的高度和宽度和增加行间距。
CSS 尺寸 (Dimension)属性
属性 | 描述 |
---|---|
height | 设置元素的高度 |
line-height | 设置行高 |
max-height | 设置元素的最大高度 |
max-width | 设置元素的最大宽度 |
min-height | 设置元素的最小高度 |
min-width | 设置元素的最小宽度 |
width | 设置元素的宽度 |
代码实例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
img.normal
{
height:auto;
}
img.big
{
height:20%;
}
p.ex
{
max-height:50px
width:100px;
}
</style>
</head>
<body>
<img class="normal" src="demo.png" width="95" height="84" />
<br>
<img class="big" src="demo.png" width="95" height="84" />
<p class="ex">The height and width of this paragraph is 100px.</p>
<p>This is some text in a paragraph. This is some text in a paragraph.This is some text in a paragraph. This is some text in a paragraph.This is some text in a paragraph. This is some text in a paragraph.</p>
</body>
</html>