跳转到帖子
在手机APP中查看

一个更好的浏览方法。了解更多

OKCCN - XenForo & IPS Plugin Marketplace

主屏幕上的全屏APP,带有推送通知、徽章等。

在iOS和iPadOS上安装此APP
  1. 在Safari中轻敲分享图标
  2. 滚动菜单并轻敲添加到主屏幕
  3. 轻敲右上角的添加按钮。
在安卓上安装此APP
  1. 轻敲浏览器右上角的三个点菜单 (⋮) 。
  2. 轻敲添加到主屏幕安装APP
  3. 轻敲安装进行确认。
  • 选择语言

CSS Text Effects

推荐的帖子

  • 行政经理

CSS Text Effects


CSS Text Effects

CSS has some properties to handle text overflow, word wrapping, line breaking rules and writing modes.

In this chapter you will learn about the following properties:

  • text-overflow - Specifies how to handle overflowed content
  • word-wrap - Allows long words to be able to be broken and wrap onto the next line
  • word-break - Specifies line breaking rules
  • writing-mode - Specifies whether lines of text are laid out horizontally or vertically

CSS text-overflow Property

The CSS text-overflow property specifies how overflowed content that is not displayed should be signaled to the user. It can be clipped or rendered with ellipsis (...).

Both of the following properties are required for text-overflow to take effect:

  • white-space: nowrap;
  • overflow: hidden;

Here, the overflowed content is clipped:

This is some long text that will not fit in the box

Here, the overflowed content is rendered with ellipsis (...):

This is some long text that will not fit in the box

The CSS code is as follows:

Example

p.test1 {
  width: 200px;
  border: 1px solid #000000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

p.test2 {
  width: 200px;
  border: 1px solid #000000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
Try it Yourself »

The following example shows how you can display the overflowed content when hovering over the element:

Example

p:hover {
  overflow: visible;
}
Try it Yourself »


CSS word-wrap Property

The CSS word-wrap property allows long words to be able to be broken and wrap onto the next line. 

If a word is too long to fit within an area, it expands outside:

This paragraph contains a very long word: thisisaveryveryveryveryveryverylongword. The long word will break and wrap to the next line.

The word-wrap property allows you to force the text to wrap - even if it means splitting it in the middle of a word:

This paragraph contains a very long word: thisisaveryveryveryveryveryverylongword. The long word will break and wrap to the next line.

The CSS code is as follows:

Example

Allow long words to be able to be broken and wrap onto the next line:

p {
  word-wrap: break-word;
}
Try it Yourself »

CSS word-break Property

The CSS word-break property specifies how words should break when reaching the end of a line.

This property can take one of the following values:

  • normal - This is default. Uses the default line breaking rules of the language
  • break-all - Allows words to be broken at any character to prevent overflow
  • keep-all - Prevents words from breaking

Here, we use normal:

This paragraph contains some text. This line will-break-at-hyphens.

Here, we use break-all:

This paragraph contains some text. The lines will break at any character.

The CSS code is as follows:

Example

p.test1 {
  word-break: normal;
}

p.test2 {
  word-break: break-all;
}
Try it Yourself »

CSS writing-mode Property

The CSS writing-mode property specifies whether lines of text are laid out horizontally or vertically.

This property can take one of the following values:

  • horizontal-tb - Default. The text flows horizontally from left to right, vertically from top to bottom
  • vertical-rl - The text flows vertically from top to bottom, horizontally from right to left
  • vertical-lr - The text flows vertically from top to bottom, horizontally from left to right

Here is a text with a span element with a vertical-rl writing-mode.

The following example shows some different writing modes:

Example

p.test1 {
  writing-mode: horizontal-tb;
}

span {
  writing-mode: vertical-rl;
}

p.test2 {
  writing-mode: vertical-rl;
}
Try it Yourself »


CSS Text Effect Properties

The following table lists the CSS text effect properties:

Property Description
text-justify Specifies how justified text should be aligned and spaced
text-overflow Specifies how overflowed content that is not displayed should be signaled to the user
word-break Specifies line breaking rules for non-CJK scripts
word-wrap Allows long words to be able to be broken and wrap onto the next line
writing-mode Specifies whether lines of text are laid out horizontally or vertically

参与讨论

你可立刻发布并稍后注册。 如果你有帐户,立刻登录发布帖子。

游客
回帖…

帐户

导航

搜索

搜索

配置浏览器推送通知

Chrome (安卓)
  1. 轻敲地址栏旁的锁形图标。
  2. 轻敲权限 → 通知。
  3. 调整你的偏好。
Chrome (台式电脑)
  1. 点击地址栏中的挂锁图标。
  2. 选择网站设置。
  3. 找到通知选项并调整你的偏好。