CSS尺寸(Dimension)

CSS尺寸(Dimension) 首页 / CSS入门教程 / CSS尺寸(Dimension)

无涯教程具有以下属性,可让您控制盒子的尺寸。

  • height           : 属性用于设置盒子的高度。

  • width            : 属性用于设置盒子的宽度。

  • line-height   : 属性用于设置一行文本的高度。

  • max-height  : 属性用于设置盒子可以达到的最大高度。

  • min-height   : 属性用于设置盒子的最小高度。

  • max-width    : 属性用于设置盒子可以的最大宽度。

  • min-width    :  属性用于设置盒子的最小宽度。

Height and Width  属性

height 和 width 属性允许您设置框的高度和宽度。它们可以采用长度,百分比或关键字auto的值。

<html>
   <head>
   </head>

   <body>
      <p style="width:400px; height:100px; border:1px solid red; padding:5px; margin:10px;">
         This paragraph is 400pixels wide and 100 pixels high
      </p>
   </body>
</html> 

它将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css-dimension.html

来源:LearnFk无涯教程网

Line-height  属性

line-height 属性允许您增加文本行之间的间距。 line-height属性的值可以是数字,长度或百分比。

<html>
   <head>
   </head>

   <body>
      <p style="width:400px; height:100px; border:1px solid red; padding:5px; margin:10px; line-height:30px;">
         This paragraph is 400pixels wide and 100 pixels high and here line height is 30pixels.
         This paragraph is 400 pixels wide and 100 pixels high and here line height is 30pixels.
      </p>
   </body>
</html>

它将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css-dimension.html

来源:LearnFk无涯教程网

Max-height  属性

max-height 属性允许您指定盒子的最大高度。 max-height属性的值可以是数字,长度或百分比。

<html>
   <head>
   </head>  
   <body>
      <p style="width:400px; max-height:10px; border:1px solid red; padding:5px; margin:10px;">
         This paragraph is 400px wide and max height is 10px
         This paragraph is 400px wide and max height is 10px
         This paragraph is 400px wide and max height is 10px
         This paragraph is 400px wide and max height is 10px
      </p>
      <br>
      <br>
      <br>
      <img alt="logo" src="/css/images/logo.png" width="195" height="84" />
   </body>
</html> 

它将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css-dimension.html

来源:LearnFk无涯教程网

Min-height  属性

min-height 属性允许您指定盒子的最小高度。 min-height属性的值可以是数字,长度或百分比。

<html>
   <head>
   </head>

   <body>
      <p style="width:400px; min-height:200px; border:1px solid red; padding:5px; margin:10px;">
         This paragraph is 400px wide and min height is 200px
         This paragraph is 400px wide and min height is 200px
         This paragraph is 400px wide and min height is 200px
         This paragraph is 400px wide and min height is 200px
      </p>
      <img alt="logo" src="/css/images/logo.png" width="95" height="84" />
   </body>
</html> 

它将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css-dimension.html

来源:LearnFk无涯教程网

Max-width  属性

max-width 属性允许您指定盒子的最大宽度。 max-width属性的值可以是数字,长度或百分比。

<html>
   <head>
   </head>

   <body>
      <p style="max-width:100px; height:200px; border:1px solid red; padding:5px; margin:10px;">
         This paragraph is 200px high and max width is 100px
         This paragraph is 200px high and max width is 100px
         This paragraph is 200px high and max width is 100px
         This paragraph is 200px high and max width is 100px
         This paragraph is 200px high and max width is 100px
      </p>
      <img alt="logo" src="/images/css.gif" width="95" height="84" />
   </body>
</html>

这将产生以下输出-

Min-width  属性

min-width 属性允许您指定盒子的最小宽度。 min-width属性的值可以是数字,长度或百分比。

<html>
   <head>
   </head>

   <body>
      <p style="min-width:400px; height:100px; border:1px solid red; padding:5px; margin:10px;">
         This paragraph is 100px high and min width is 400px
         This paragraph is 100px high and min width is 400px
      </p>
      <img alt="logo" src="/css/images/css.gif" width="95" height="84" />
   </body>
</html> 

它将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css-dimension.html

来源:LearnFk无涯教程网

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

教程推荐

AI 音视频创作入门课 -〔唐子轩〕

云原生基础架构实战课 -〔潘野〕

React Native 新架构实战课 -〔蒋宏伟〕

Go 语言项目开发实战 -〔孔令飞〕

A/B测试从0到1 -〔张博伟〕

动态规划面试宝典 -〔卢誉声〕

TensorFlow快速入门与实战 -〔彭靖田〕

Go语言核心36讲 -〔郝林〕

人工智能基础课 -〔王天一〕

好记忆不如烂笔头。留下您的足迹吧 :)