search
HomeWeb Front-endHTML TutorialWeb前端新人笔记之文本属性 - 来治猩猩的我

<span style="font-family: Microsoft YaHei; font-size: 15px;">前一段时间因工作时间减缓了更新笔记的时间。我也不知道有没有会观看并且能不能帮到一些初学者,这只是我的一些小随笔而已。<br>当然我也希望的的每一篇随笔都可以帮到更多的想要学习前端开发的初学者们,更希望你们也可以从中体会到、领悟到一些新的知识作为积累并加以巩固。<br>像我一样写下自己每时每刻的成长记录。</span>

文本属性

<span style="font-size: 16px;"><strong><span style="font-family: Microsoft YaHei;">文本缩进<br></span></strong></span><span style="font-family: Microsoft YaHei; font-size: 15px;">  将Web页面上的一个段落第一行缩进,这是一种最常用的文本格式化效果。有的网站在段落的第一个字母前放一个很小的透明图像,这些图像将文本推到后面来制造一种缩进文本的感觉。另外一些网站则使用完全标准的空格(spacer)标记。而在CSS中有一种更好地方法实现文本缩进。那就是text-indent属性。<br><img src="/static/imghwm/default1.png" data-src="http://images2015.cnblogs.com/blog/707288/201605/707288-20160503090414185-958006375.png" class="lazy" alt=""><br>通过使用text-indent属性,所有元素的第一行都可以缩进一个给定长度,甚至该长度可以是负值。<br></span>
<span style="color: #008000;">/*</span><span style="color: #008000;">
*    text-indent的单位是em
</span><span style="color: #008000;">*/</span><span style="color: #000000;">
p{
      text</span>-<span style="color: #000000;">indent:3em;  
 }<br><span style="color: #000000;"><br>p{<br>      text-<span style="color: #000000;">indent:-3em;
 }<br>/*<br>*  用百分比实现文本缩进<br>*/<br>p{<br>    text-indent:3%;<br>}</span></span></span>
<span style="font-size: 16px;"><strong> 水平对齐<br></strong>   <span style="font-size: 15px;">与</span><span style="font-size: 15px;">text-indent相比,text-align是一个更基本的属性,它会影响一个元素中的文本行相互之间的对齐方式。。<br><img src="/static/imghwm/default1.png" data-src="http://images2015.cnblogs.com/blog/707288/201605/707288-20160503091608607-581686070.png" class="lazy" alt=""><br><strong><span   style="max-width:90%">注意</span></strong>:将块级元素或表元素居中,这要通过在这些元素上适当地设置左、右外边距来实现。<br><strong><span style="font-size: 16px;">行高<br></span></strong><span style="font-size: 15px;">  line-height属性是指文本行基线之间的距离,而不是字体的大小。它确定了将各个元素框的高度增加或者减少。<br><img src="/static/imghwm/default1.png" data-src="http://images2015.cnblogs.com/blog/707288/201605/707288-20160503092130404-203272595.png" class="lazy" alt=""></span></span></span>

 垂直对齐文本

  在CSS中,vertical-algin属性只应用于行内元素和替换元素。表单输入元素和图像,verticl-align属性不能继承。

  文本转换

 

  默认值none对文本不做任何改动,将使用源文档中原有的大小写。顾名思义,uppercase和lowercase将文本转化为全大写或全小写字符。

  capitalize只对每个单词的首个字母大写。

  文本装饰

  

  underline会对元素加下划线;

  overline会在元素顶端加上划线;

  line-through则在文本中间画一个贯穿线。等价于HTML中的S和Strike;

  blink会让文本闪烁;

  文本阴影

 

<span style="color: #008000;">/*</span><span style="color: #008000;">
*  要定义一个相对于文本向右移5像素向下偏移0.5的绿色阴影,而且不模糊可以写作       
</span><span style="color: #008000;">*/</span><span style="color: #000000;">
p{
     text</span>-shadow: green 50x <span style="color: #800080;">0</span><span style="color: #000000;">.5em;
   }</span>

  处理空白符

  

  

  文本方向

  

  direcation属性影响块级元素中的文本书写方向、表中列布局的方向、内容水平填充其元素框的方向、以及两端对齐元素最后一行的位置。

  对于行内元素,只有短unicode-bidi属性设置为embed或bidi-override时才会应用direction属性。

  

  normal:元素不会对双向算法打开附加的一层嵌套,对于行内元素,顺序的隐式重排会跨元素边界进行。

  embed:如果是一个行内元素,这个值对于双向算法会打开附加的一层嵌套,这个嵌套层方向由direction属性指定。

    会在元素内部隐式的完成顺序重排。

  bidi-override:这会为行内元素创建一个覆盖,对于块级元素,将为不在另一块中的额行内后代创建一个覆盖。

    这说明,顺序重排字啊元素内部严格按direction属性进行,忽略了双向算法的隐式部分。

 


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software