日期:2014-05-17  浏览次数:20852 次

CSS文集《The CSS Anthology》 第二章 文本格式化及其它基础知识 (2)
11. 为段落文本加高亮
<div>
	<h1 class="pg39">
		Chinese-style Stuffed Peppers
	</h1>
	Below, I've created a CSS rule for all te level-one headings in a document. The result is shown in Figure 2.11.
	hello, world......	
</div>

<div class="pg39">
	<h1 class="pg39">
		Chinese-style Stuffed Peppers
	</h1>
	<p>
	These <span class="pg39_highlight">stuffed peppers</span> are lovely as a starter, or as a side sish for a Chinese meal. They also go down well as part of a buffet, and even children seem to like them.
	</p>
</div>

/* 设置文本高亮 */
.pg39_highlight {
	background-color : #FFFFCC;
	color : #B22222;
}



图2-6


12. 设置段落行高
使用line-height属性。
<div class="pg40">
	<p class="pg40">
	Once upon a time, a mouse, a bird, and a sausage entered into partnership and set up house together. For a long time all went well; they lived in great comfort, and prospered so far as to be able to add considerably to their stores. The bird's duty was to fly daily into the wood and bring in fuel, the mouse fetched the water, and the sausage saw to the cooking.
	</p>
</div>


p.pg40 {
	font : 0.9em Verdana, Geneva, Arial, Helvetica, sans-serif;
	/* 设置行高,2.0是比率值,指比缺省设置大两倍。 */
	line-height : 2.0;
}




图2-7


13. pg42 使段落四周空白均匀
设置text-align属性为justify。可设值包括:right, left, center。
<div class="pg42">
	<p class="pg42">
	Once upon a time, a mouse, a bird, and a sausage entered into partnership and set up house together. For a long time all went well; they lived in great comfort, and prospered so far as to be able to add considerably to their stores. The bird's duty was to fly daily into the wood and bring in fuel, the mouse fetched the water, and the sausage saw to the cooking.
	</p>
</div>

p.pg42 {
	/* 设置文本自动调节——左右两边空白均匀 */
	text-align : justify; /* 可设值包括:right, left, center */
	font : 1em Verdana, Geneva, Arial, Helvetica, sans-serif;
	line-height : 2.0;
}




图2-8


14. 为hr标签(水平分隔线)加样式
水平分隔线可以设置属性,如边框,背景颜色,颜色,高度,宽度等。
<div class="pg43">
	<p>
	Once upon a time, a mouse, a bird, and a sausage entered into partnership and set up house together. For a long time all went well; they lived in great comfort, and prospered so far as to be able to add considerably to their stores. The bird's duty was to fly daily into the wood and bring in fuel, the mouse fetched the water, and the sausage saw to the cooking.
	</p>
	<hr class="pg43"/>
	<p>
	Once upon a time, a mouse, a bird, and a sausage entered into partnership and set up house together. For a long time all went well; they lived in great comfort, and prospered so far as to be able to add considerably to their stores. The bird's duty was to fly daily into the wood and bring in fuel, the mouse fetched the water, and the sausage saw to the cooking.
	</p>
</div>


hr.pg43 {
	border : none;
	background-color : #ADD8E6;
	color : #ADD8E6;
	height : 1px;
	width : 80%;
}