CSS text-align 属性
目录
属性定义及使用说明
text-align 属性指定元素文本的水平对齐方式。
默认值: | 如果 direction 属性是 ltr,则默认值为 left;如果 direction 属性是 rtl,则默认值为 right。 |
---|---|
继承: | yes |
版本: | CSS1 |
JavaScript 语法: | object.style.textAlign=”right” |
属性值
值 | 描述 |
---|---|
left | 把文本排列到左边。默认值:由浏览器决定。 |
right | 把文本排列到右边。 |
center | 把文本排列到中间。 |
justify | 实现两端对齐文本效果。 |
inherit | 规定应该从父元素继承 text-align 属性的值。 |
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
紧跟在 -webkit-, -ms- 或 -moz- 前的数字为支持该前缀属性的第一个浏览器版本号。
属性 | |||||
---|---|---|---|---|---|
text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
实例
h1, h2, 和 h3 元素设置文本的对齐方式:
<style> h1 {text-align:center} h2 {text-align:left} h3 {text-align:right} </style> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> <h3>This is heading 3</h3> </body>
效果如下:
相关文章
CSS 教程: CSS text 文本属性
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
码云笔记 » CSS text-align 属性
码云笔记 » CSS text-align 属性