所属分类:web前端开发
CSS(层叠样式表)是一个强大的工具,用于控制网站上文本的布局和外观。在本文中,我们将学习如何使用 CSS 更改段落中文本的大小写。
当涉及到网站上的文本样式时,基本且常见的样式选项之一是更改文本的大小写,我们可以使用 CSS 中的 text-transform 属性轻松完成此操作。 text-transform 属性可以采用以下值之一 -
“大写”会将所选元素中每个单词的第一个字母大写。
“大写”会将所选元素中的所有文本转换为大写字母。
“小写”会将所选元素中的所有文本转换为小写字母。
要更改段落中文本的大小写,首先我们需要使用 CSS 选择器选择段落元素。例如,要将段落中文本的大小写更改为大写,我们将使用以下 CSS -
1 2 3 | p { text-transform: uppercase; } |
以下是使用 CSS 更改段落中文本大小写的示例。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | < html > < head > < title >Change the cases of text in paragraphs using CSS</ title > < style > body{ text-align:center; } .capitalize{ color: blue; text-transform: capitalize; } .uppercase{ color: red; text-transform: uppercase; } .lowercase{ color: green; text-transform: lowercase; } </ style > </ head > < body > < h2 >Change the cases of text in paragraphs using CSS</ h2 > < p class = "capitalize" >capitalize the first letter of each word in the selected element</ p > < p class = "uppercase" >Converted all the text in the selected element to uppercase letters</ p > < p class = "lowercase" >CONVERTED ALL THE TEXT IN SELECTES ELEMENT TO LOWERCASE LETTERS</ p > </ body > </ html > |
要更改段落中文本的大小写,CSS 中的 text-transform 属性是更改段落中文本大小写的好方法。