8.8. CSS3 text effect

发布时间 : 2025-10-25 13:34:12 UTC      

Page Views: 10 views

8.8.1. CSS3 text effect

Several new text features are included in CSS3.

In this chapter, you will learn about the following text properties:

  • Text-shadow

  • Box-shadow

  • Text-overflow

  • Word-wrap

  • Word-break

8.8.2. Browser support

Attribute

Text-shadow

4.0

10.0

3.5

4.0

9.5

Box-shadow

10.04.0-webkit-

9.0

4.03.5-moz-

5.1 3.1-webkit-

10.5

Text-overflow

4.0

6.0

7.0

3.1

11.09.0-o-

Word-wrap

23.0

5.5

3.5

6.1

12.1

Word-break

4.0

5.5

15.0

3.1

15.0

8.8.3. Text Shadow of CSS3

In CSS3 text-shadow property applies to text shadows.

Image0

You specified horizontal shadows, vertical shadows, blurred distances, and the color of shadows:

Example

Add shadows to the title:

h1 { text-shadow: 5px 5px 5px #FF0000; } 

8.8.4. CSS3 box-shadow attribute

CSS3 in CSS3 box-shadow property applies to box shadows

Example

div { box-shadow: 10px 10px 5px #888888; } 

8.8.5. Next, add color to the shadow.

Example:

div { box-shadow: 10px 10px grey; } 

8.8.6. Next, add a blur effect to the shadow

Example

div { box-shadow: 10px 10px 5px grey; } 

8.8.7. You can also add shadow effects to:: before and:: after pseudo elements

Example

#boxshadow { position: relative; b ox-shadow: 1px 2px 4px rgba(0, 0, 0, .5); pa dding: 10px; bac kground: white; } #boxshadow img { width: 100%; border: 1px solid #8a4419; border-style: inset; } #boxshadow::after { content: ''; position: absolute; z-index: -1; /* hide shadow behind image */ box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3); width: 70%; left: 15%; /* one half of the remaining 30% */ height: 100px; bottom: 0; } 

8.8.8. A special case for the use of shadows is the card effect

Example

div.card { width: 250px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); text-align: center; } 

8.8.9. CSS3 Text Overflow attribute

The CSS3 text overflow property specifies how the overflow content should bedisplayed to the user

Example

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

8.8.10. Line feeds of CSS3

If a word is too long to fit in an area, it extends to the outside:

In CSS3, the auto-wrap attribute allows you to force text wrapping-even if it means splitting a word in the middle of it:

The CSS code is as follows:

Example

Allow long text to wrap:

p{word-wrap:break-word;} 

8.8.11. CSS3 word splitting and newline

The CSS3 word split newline property specifies the newline rule:

The CSS code is as follows:

Example

p.test1 { word-break: keep-all; } p.test2 { word-break: break-all; } 

8.8.12. New text Properties

Attribute

Description

CSS

Hanging-punctuation

Specifies whether the punctuation character is outside the wireframe.

3

Punctuation-trim

Specifies whether punctuation characters are trimmed.

3

Text-align-last

Sets how to align the last line or the line immediately before the forced newline character.

3

Text-emphasis

Applies the accent tag and the foreground color of the accent tag to the element’s text.

3

Text-justify

Specifies the alignment method to be used when text-align is set to justify.

3

Text-outline

Specifies the outline of the text.

3

Text-overflow

Specifies what happens when a text overflow contains an element.

3

Text-shadow

Add shadows to the text.

3

Text-wrap

Specifies the line wrapping rules for the text.

3

Word-break

Stipulate the line wrapping rules for non-Chinese, Japanese and Korean texts.

3

Word-wrap

Allows you to split long, indivisible words and wrap them to the next line.

3

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。