css 宽度高度等于宽度_CSS中的高度和宽度

css 宽度高度等于宽度

The height and width properties allow you to set the height and width properties of an element.

height和width属性使您可以设置元素的height和width属性

Height and width properties are crucial for any website because it helps in making the websites more space-efficient and further adds more to the styles of the site as well.

高度和宽度属性对于任何网站都是至关重要的,因为它有助于使网站更节省空间,并进一步增加网站的样式。

The height and width properties do not include any padding, margins or borders instead they influence the padding, margins, and borders of the element.

height和width属性不包含任何padding , margin或border,它们会影响元素的padding,margin和borders。

Syntax:

句法:

    Element{
        height: 200px/60%
        width: 200px/70%
    }

Example:

例:

<!DOCTYPE html>
<title>heading</title>
<style>
    div {
        height: 200px;
        width: 60%;
        background-color: lightblue;
    }
</style>
<div>
    The div has height and weight property.
</div>

Output

输出量

The div has height and weight property.

div具有height和weight属性。

height and width css 1

The height and width may have the following set of values:

高度和宽度可以具有以下一组值:

  • auto - This is a default value. The browser itself calculates the height and width

    自动 -这是默认值。 浏览器本身会计算高度和宽度

  • length -It helps in defining the height/width in px, cm, etc

    长度 -有助于定义以px,cm等为单位的高度/宽度

  • % - It helps in defining the height/width in percent of the containing block

    -它有助于定义包含块的百分比的高度/宽度

  • initial - This sets the height/width to its default value

    初始 -将高度/宽度设置为其默认值

  • inherit - The height and width will be inherited from its parent value

    继承 -高度和宽度将从其父值继承

Setting the max-width and max-height:

设置最大宽度和最大高度:

The max-width and max-height properties are used to set the maximum width and height of an element.

max-width和max-height属性用于设置元素的最大宽度和高度。

The properties can be specified into px, cm or percent.

可以将属性指定为px,cm或百分比。

Using max-width and max-height the browser with small windows can be handled more neatly.

使用max-width和max-height ,可以更轻松地处理带有小窗口的浏览器。

Example:

例:

<!DOCTYPE html>
<title>heading</title>
<style>
    div {
        max-height: 100px;
        max-width: 95px;
        background-color: green;
    }
</style>
<div>
    The div has 'max-height' and 'max-width' applied.
</div>

Output:

输出:

The div has 'max-height' and 'max-width' applied.

div应用了“最大高度”和“最大宽度”。

height and width css 2

Setting the min-width and min-height

设置最小宽度和最小高度

It helps in constraining the width and height of an element to a minimum value.

它有助于将元素的宽度和高度限制为最小值。

Example:

例:

<!DOCTYPE html>
<title>heading</title>
<style>
    div {
        min-height: 390px;
        min-width: 95px;
        background-color: red;
    }
</style>
<div>
    The div has 'min-height' and 'min-width' applied.
</div>

Output

输出量

The div has 'min-height' and 'min-width' applied.

div应用了“最小高度”和“最小宽度”。

height and width css 3

Some CSS dimension properties

一些CSS尺寸属性

PropertyDescription
heightSets the height of an element
min-heightSets the minimum height of an element
max-heightSets the maximum height of an element
widthSets the width of an element
max-widthSets the maximum width of an element
min-widthSets the minimum width of an element
属性 描述
高度 设置元素的高度
最小高度 设置元素的最小高度
最大高度 设置元素的最大高度
宽度 设置元素的宽度
最大宽度 设置元素的最大宽度
最小宽度 设置元素的最小宽度

翻译自: https://www.includehelp.com/code-snippets/height-and-width-in-css.aspx

css 宽度高度等于宽度

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值