css:文本两端对齐

简介: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>css文本两端对齐详解及实例</title>

<style type="text/css">
/*
两端对齐大家都知道text-align:justify;

text-justify确不曾被人们所熟悉,它是干什么的呢?。先来看下语法。

语法:text-justify : auto |inter-word | newspaper | distribute | distribute-all-lines | inter-ideograph 
参数: 
auto :允许浏览器用户代理确定使用的两端对齐法则 
inter-word :通过增加字之间的空格对齐文本。该行为是对齐所有文本行最快的方法。它的两端对齐行为对段落的最后一行无效 
newspaper : 通过增加或减少字或字母之间的空格对齐文本。是用于拉丁文字母表两端对齐的最精确格式 
distribute :处理空格很像newspaper,适用于东亚文档。尤其是泰国 
distribute-all-lines :两端对齐行的方式与distribute相同,也同样不包含两段对齐段落的最后一行。适用于表意字文档 
inter-ideograph : 为表意字文本提供完全两端对齐。他增加或减少表意字和词间的空格 
说明: 
设置或检索对象内文本的对齐方式。 
对应的脚本特性为textJustify。
*/
.w1{ width:500px;}
.a1{background:#00FF00;
 text-align:justify;/*firefox*/
 text-justify:inter-ideograph;/*ie*/
 -ms-text-justify: inter-ideograph;/*ie10 ;auto | distribute | distribute-all-lines | distribute-center-last | inter-cluster | inter-ideograph | inter-word | kashida | newspaper*/
}
.a2{ background:#FFFF00;}
.geovindu
{
 text-align:justify;/*firefox*/
 text-justify:inter-ideograph;/*ie*/

}
</style>
<style type="text/css">
body { margin-right: 0.7em; }
.just { text-align: justify; }
.summ { font-size : 105%; text-indent : 0;
            margin-left : 10%; margin-right : 10%;
            padding : 0.2em 0.1em 0.2em 0.4em;}
.minitoc { width: auto; }
body { font-family: Cambria, Georgia, Palatino Linotype; }
th, td { vertical-align: top; }
.important {
  clear: both;
  max-width: 12em;
  float: right;
}
/*small code, .small code, .deem code { font-size : 95%; }*/
 
p.literary, .literary p { text-indent : 1em;
    margin-bottom : 0;
    margin-top : 0; }

p.first { text-indent : 0 !important; }

p.start { text-indent : 0;
    margin-bottom : 0.5ex; }

p.start:first-letter { font-size : 200%; font-weight : bold;
   color : #060; background : #fff ; }
 
</style>

</head>
<body>
<p>原效果:</p>
<div class="w1 a2">css如何让一行内的文字两端对齐? text-align:justify;. 这是一篇来自百度知道的问题. 顶部. 热点频道推荐: C/S开发| 数据库| WEB </div>
<p>两端对齐后产效果:</p>

<div class="w1 a1">css如何让一行内的文字两端对齐?布丁足迹为您答案 text-align:justify;. 这是一篇来自百度知道的问题. 顶部. 热点频道推荐: C/S开发| 数据库| WEB </div>

<div style="color:#FF0000; font-size:12px; padding-top:10px;">text-justify语法: <br />
  text-justify : auto |inter-word | newspaper | distribute | distribute-all-lines | inter-ideograph <br />
  参数: <br />
  auto :允许浏览器用户代理确定使用的两端对齐法则 <br />
  inter-word :通过增加字之间的空格对齐文本。该行为是对齐所有文本行最快的方法。它的两端对齐行为对段落的最后一行无效 <br />
  newspaper : 通过增加或减少字或字母之间的空格对齐文本。是用于拉丁文字母表两端对齐的最精确格式 <br />
  distribute :处理空格很像newspaper,适用于东亚文档。尤其是泰国 <br />
  distribute-all-lines :两端对齐行的方式与distribute相同,也同样不包含两段对齐段落的最后一行。适用于表意字文档 <br />
  inter-ideograph : 为表意字文本提供完全两端对齐。他增加或减少表意字和词间的空格 <br />
  说明:<br />
设置或检索对象内文本的对齐方式。 <br />
对应的脚本特性为textJustify。</div>
<div class="geovindu">两端对齐大家都知道text-align:justify;

text-justify确不曾被人们所熟悉,它是干什么的呢?。先来看下语法。

语法:text-justify : auto |inter-word | newspaper | distribute | distribute-all-lines | inter-ideograph 
参数: 
auto :允许浏览器用户代理确定使用的两端对齐法则 
inter-word :通过增加字之间的空格对齐文本。该行为是对齐所有文本行最快的方法。它的两端对齐行为对段落的最后一行无效 
newspaper : 通过增加或减少字或字母之间的空格对齐文本。是用于拉丁文字母表两端对齐的最精确格式 
distribute :处理空格很像newspaper,适用于东亚文档。尤其是泰国 
distribute-all-lines :两端对齐行的方式与distribute相同,也同样不包含两段对齐段落的最后一行。适用于表意字文档 
inter-ideograph : 为表意字文本提供完全两端对齐。他增加或减少表意字和词间的空格 
说明: 
设置或检索对象内文本的对齐方式。 
对应的脚本特性为textJustify。
ie 10:(注釋自己谷歌查找)
-ms-text-justify: auto | distribute | distribute-all-lines | distribute-center-last | inter-cluster | inter-ideograph | inter-word | kashida | newspaper
</div>

<h2><a name="def">What is justification?</a></h2>

<p align="justify"  style="width:512px;">
<dfn><a name="prologue" href="http://www.m-w.com/cgi-bin/dictionary?justify"
title="WWWebster dictionary entry for "justify""
>Justifying</a></dfn> text can mean different things,
but
here we consider "justification on both sides", or "double justification",
where text lines are justified both on the left and on the right.
That is, all lines except (usually) the last one have equal width;
the method used to achieve that is typically to leave extra space
between words as needed. Such justification is very common in books
and other printed matter and often regarded as an essential property
of quality print?ing. On computer screens, it's more debatable.
But before discussing
<a href="http://geovindu.blog.163.com/blog/#why"><em>whether</em> we should try to justify text</a>
on our Web pages,
we'll discuss the <em>how</em> it could be done.</p> 

</body>

</html>

目录
相关文章
|
1月前
|
前端开发
css文本属性
css文本属性
13 0
|
2天前
|
前端开发 容器
CSS 超出内容... 或者多行省略及两端对齐及超出多行居中显示
该文本是关于CSS样式技巧的摘要:包括单行和多行文本超出时的省略显示方法,以及Flex布局的两端对齐和一行超出后多行居中的示例代码。
|
11天前
|
前端开发 UED
【专栏:CSS 基础篇】CSS 字体与文本样式:美化你的网页内容
【4月更文挑战第30天】网页设计中,字体和文本样式至关重要,影响视觉效果和用户体验。CSS允许设计师设置字体家族、大小、颜色、加粗、倾斜、行高和对齐方式等。高级特性包括引入外部字体和使用字体变体。响应式设计适应不同设备,确保良好阅读体验。实际案例和最佳实践强调易读性和一致性。掌握这些技巧能提升网页美感和用户交互,创造更多可能。
|
12天前
|
前端开发
css样式字体、文本、背景属性,盒子模型详解,轻松调教出优美的字体和网页背景色
css样式字体、文本、背景属性,盒子模型详解,轻松调教出优美的字体和网页背景色
|
26天前
|
XML 编解码 前端开发
css设计文本样式 前端开发入门笔记(十二)
css设计文本样式 前端开发入门笔记(十二)
7 0
|
26天前
|
前端开发 容器
CSS3属性详解(一)文本 盒模型中的 box-ssize 属性 处理兼容性问题:私有前缀 边框 背景属性 渐变 前端开发入门笔记(七)
CSS3属性详解(一)文本 盒模型中的 box-ssize 属性 处理兼容性问题:私有前缀 边框 背景属性 渐变 前端开发入门笔记(七)
28 2
|
2月前
|
前端开发
CSS文本单行溢出显示省略号与多行溢出显示省略号(简单易懂)
CSS文本单行溢出显示省略号与多行溢出显示省略号(简单易懂)
|
2月前
编程笔记 html5&css&js 007 HTML文本:段落和格式
编程笔记 html5&css&js 007 HTML文本:段落和格式
|
2月前
编程笔记 html5&css&js 006 HTML文本:标题
编程笔记 html5&css&js 006 HTML文本:标题
|
3月前
|
移动开发 前端开发 JavaScript
H5+CSS3+JS逆向前置——HTML1、H5文本元素
H5+CSS3+JS逆向前置——HTML1、H5文本元素
28 0