AI工具推荐 视频效率加速

CSS 尺寸 (Dimension)

CSS 尺寸 (Dimension)属性

属性描述
height设置元素的高度。
line-height设置行高。
max-height设置元素的最大高度。
max-width设置元素的最大宽度。
min-height设置元素的最小高度。
min-width设置元素的最小宽度。
width设置元素的宽度。

实例

使用百分比设置图像的高度

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文网(php.cn)</title>
    <style>
        html {height:100%;}
        body {height:100%;}
        img.normal {height:auto;}
        img.big {height:30%;}
        img.small {height:10%;}
    </style>
</head>

<body>
<img class="normal" src="/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /><br>
<img class="big" src="/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /><br>
<img class="small" src="/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" />
</body>
</html>

运行程序尝试一下


实例

设置元素的最低高度

       <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文网(php.cn)</title>
    <style>
        p
        {
            min-height:100px;
            background-color:yellow;
        }
    </style>
</head>

<body>
<p>这一段的最小高度设置为100 px。</p>
</body>
</html>

运行程序尝试一下




继续学习
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style> html {height:100%;} body {height:100%;} img.normal {height:auto;} img.big {height:30%;} img.small {height:10%;} </style> </head> <body> <img class="normal" src="https://img.php.cn/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /><br> <img class="big" src="https://img.php.cn/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /><br> <img class="small" src="https://img.php.cn/upload/course/000/000/006/5809800b44336872.jpg" width="95" height="84" /> </body> </html>
提交重置代码
  • 评论
  • 课件下载

女神的闺蜜爱上我

CSS比PHP学起来简单呀。。

9年前      0

学习ing

设置上下左右都居中怎么做啊

9年前      0

Alway.以为

设置宽和高的吗

9年前      0

大神,求带!

这节是设置最大和最小的,容易学

9年前      0

小天

这节的内容就很容易懂了,width 宽 height 高

9年前      0

课件暂不提供下载,工作人员正在整理中,后期请多关注该课程~