本文介绍了 CSS中 text-align属性指定元素文本的水平对齐方式。
CSS中 text-align属性指定元素文本的水平对齐方式。
属性值:
- left : 把文本排列到左边。默认值:由浏览器决定。
- right : 把文本排列到右边。
- center : 把文本排列到中间。
- justify : 实现两端对齐文本效果。
- inherit : 规定应该从父元素继承 text-align 属性的值。
实例:
<html>
<head>
<meta charset="utf-8">
<title>IT懒猫 www.catroom.com.cn</title>
<style>
h1 {text-align:center}
h2 {text-align:left}
h3 {text-align:right}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
</body>
</html>
效果:
发表评论
取消回复