用户登录
用户注册

分享至

wordspacing属性

  • 作者: 网友3187355
  • 来源: 51数据库
  • 2020-04-21

1.css word

word-spacing 属性增加或减少单词间的空白(即字间隔)。

该属性定义元素中字之间插入多少空白符。针对这个属性,“字” 定义为由空白符包围的一个字符串。如果指定为长度值,会调整字之间的通常间隔;所以,normal 就等同于设置为 0。允许指定负长度值,这会让字之间挤得更紧。

例如下面的例子:

<html>

<head>

<style type="text/css">

p.spread {word-spacing: 30px;}

p.tight {word-spacing: -0.5em;}

</style>

</head>

<body>

<p class="spread">This is some text. This is some text.</p>

<p class="tight">This is some text. This is some text.</p>

</body>

</html>

2.css word

word-spacing 属性增加或减少单词间的空白(即字间隔)。

该属性定义元素中字之间插入多少空白符。针对这个属性,“字” 定义为由空白符包围的一个字符串。

如果指定为长度值,会调整字之间的通常间隔;所以,normal 就等同于设置为 0。允许指定负长度值,这会让字之间挤得更紧。

例如下面的例子: This is some text. This is some text.This is some text. This is some text.。

3.letter

word-spacing:设置元素文本的单词间的空白(即字间隔)。

letter-spacing:设置元素文本的字符间的空白(字符间距)。

letter-spacing和word-spacing这两个属性都用来添加它们对应的元素中的空白。letter-spacing添加字母之间的空白,而word-spacing添加每个单词之间的空白,word-spacing对中文无效。

以上资料来源:《HTML5布局之路》

4.HTML中控制文字间的距离的属性是什么

CSS 中控制横向文字间距的属性有两个,一个是字符与字符之间的间距 letter-spacing. 另一个是词与词之间的间距 word-spacing。

二者可接受的属性值均为以下四种: normal: 默认间距(letter-spacing 默认值为 0,word-spacing 默认值为 0.25em);initial: 设置为默认间距;inherit: 继承当前元素父元素的属性值;或自定义值(以 px, pt, cm, em 等为单位的值,可为负值). 例子如下: <!doctype html=""> Example A sentence with normal word spacing. A sentence with initial word spacing. A sentence with custom defined word spacing. A sentence with inherited word spacing. A sentence with negative word spacing. 使用 word-spacing 属性的中文。


A sentence with normal letter spacing. A sentence with initial letter spacing. A sentence with custom defined letter spacing. A sentence with inherited letter spacing. A sentence with negative letter spacing. 使用 letter-space 属性的中文。

输出为: 可以观察到,word-spacing 属性的设置不影响字母与字母的间距,也不影响中文等词汇之间无须空格的语言的字间距,而 letter-spacing 属性的设置则会同时影响字符间距以及单词间距,且同时作用于所有语言。

转载请注明出处51数据库 » wordspacing属性

软件
前端设计
程序设计
Java相关