css3 lineheight,CSS line-height

CSS line-height

Run

Stack editor

Unstack editor

Example

p {

font-size: 5vw;

padding: 0 5vw;

line-height: 1.8em;

}

CSS line-height is similar to leading in desktop publishing - it determines the "line height" (suprised?). This gives the impression of lines of text being closer together or further apart. Changing the line height in conjunction with using the letter-spacing, word-spacing, float properties can produce some nice looking layouts.

The CSS line-height property is similar to leading in desktop publishing — it determines the "line height". This results in lines of text appearing closer together or further apart.

On a block container element whose content is composed of inline-level elements, line-height specifies the minimal height of line boxes within the element.

On a non-replaced inline element, line-height specifies the height that is used in the calculation of the line box height.

Also see the letter-spacing and word-spacing properties.

Syntax

line-height: normal | | | | inherit

Possible Values

The line-height property accepts the following values.

normal

Specifies that the user agent should use a "reasonable" value based on the font of the element. This is typically between 1.0 and 1.2.

Specifies the line height using a length value (for example 1.3em). The specified length is used in the calculation of the line box height. Negative values are illegal.

Specifies the line height using a number value (for example 1.3). The used value of the property is this number multiplied by the element's font size. Negative values are illegal.

Specifies the line height using a percentage value (for example 130%). The computed value of the property is this percentage multiplied by the element's computed font size. Negative values are illegal.

In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:

initial

Represents the value specified as the property's initial value.

inherit

Represents the computed value of the property on the element's parent.

unset

This value acts as either inherit or initial, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.

General Information

Initial Value

normal

Applies To

All elements

Inherited?

Yes

Media

Visual

Animatable

Example Code

p {

line-height: 1.6em;

}

Official Specifications

CSS Transitions (W3C Working Draft — specifies the property as animatable)

CSS Level 2.1 (W3C Recommendation 07 June 2011)

CSS Level 1 (W3C Recommendation 17 Dec 1996)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值