控制文本的对齐方式
控制文本的对齐方式
你可以使用text-align属性的三个值left、center和right来对齐文本。更好的是,在Netscape Navigator 4.0和Internet Explorer 4.0中,你可以建立完全调整过的文本。表7.5使用了text-align属性的所有四个值(见图7.28):
表7.5 对齐方式举例
<HTML>
<HEAD>
<TITLE> Style </TITLE>
<STYLE>
<!--
.Left {text-align: left}
.Right {text-align: right}
.Center {text-align: center}
.Justify {text-align: justify}
-->
</STYLE>
</HEAD>
<BODY>
<P CLASS=Left>
This text is left aligned. See how the edges of this paragraph line up.
This text is left aligned. See how the edges of this paragraph line up.
This text is left aligned. See how the edges of this paragraph line up.
This text is left aligned. See how the edges of this paragraph line up.
This text is left aligned. See how the edges of this paragraph line up.
This text is left aligned. See how the edges of this paragraph line up.
</P>
<P CLASS=Right>
This text is right aligned. See how the edges of this paragraph line up.
This text is right aligned. See how the edges of this paragraph line up.
This text is right aligned. See how the edges of this paragraph line up.
This text is right aligned. See how the edges of this paragraph line up.
This text is right aligned. See how the edges of this paragraph line up.
This text is right aligned. See how the edges of this paragraph line up.
</P>
<P CLASS=Center>
This text is centered. I float in the middle of the screen.
This text is centered. I float in the middle of the screen.
This text is centered. I float in the middle of the screen.
This text is centered. I float in the middle of the screen.
This text is centered. I float in the middle of the screen.
This text is centered. I float in the middle of the screen.
</P>
<P CLASS=Justify>
This text is justified. See how the edges of this paragraph line up.
This text is justified. See how the edges of this paragraph line up.
This text is justified. See how the edges of this paragraph line up.
This text is justified. See how the edges of this paragraph line up.
This text is justified. See how the edges of this paragraph line up.
This text is justified. See how the edges of this paragraph line up.
</P>
</BODY>
</HTML>
图7.28 使用style sheet来对齐文本
- · 为单一的HTML标识符加上styles
- · 使用SPAN和DIV来加入styles
- · 格式化Style Sheets
- · 这一章介绍如何使用Visual Basic的Scripting版本(VBScript),Active Sever Pages的缺省脚本语言
- · 用IF
- · 用FOR循环执行重复操作
- · 使用字符串函数
- · 抽取字符串
- · 替换字符串
- · 搜索字符串
- · 比较字符串
- · 创建子例程
- · 创建函数
- · 使用随机数
- · 隐藏错误
- · 声明变量
- · 变量子类型
- · 变量数据范围
- · 声明常量
- · 创建和修改数组
- · 数组函数
- · 注释Visual Basic脚本
- · 在脚本中增加日期和时间函数
- · 格式化货币值
- · 格式化数字
- · 使用数学运算符和函数
- · 使用逻辑连接和运算符
- · 本章讲述怎样使用Active Server Pages中包含的第二种脚本语言JScript,与VBScript一样,JScript可用来扩展HTML,使它不仅仅是网页格式描述语言
- · 使用JScript函数
- · 使用分支语句(if
- · 使用循环(for
- · 指定缺省对象(with)
- · 建立JScript脚本
- · 建立JScript脚本
- · 使用数学运算(数学对象)
- · 将脚本分割成函数(函数对象)
- · 存储大量数量(数组对象)
- · 建立自定义对象
