`
deyum
  • 浏览: 35864 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

CSS文集《The CSS Anthology》 第二章 文本格式化及其它基础知识 (2)

    博客分类:
  • Web
阅读更多
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%;
}



图2-9


15. 段落缩进
为左边paddingpadding-left指定一个值,如本例指定了20像素。
<div class="pg45">
	<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/>
	<p class="pg45indent">
	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.pg45indent {
	padding-left : 30px;
}



图2-10


16. 用CSS设置段落文本全部为大写
设置段落的text-transform属性为uppercase即可。可选值还有:capitalize, lowercase, none(这是默认值)。
<div class="pg47">
	<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/>
	<p class="pg48transform">
	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.pg48transform {
	text-transform : uppercase; /* capitalize, lowercase, none(the default) */
}



图2-11


17. 改变列表风格或者去除列表项前置图标
可以设置列表风格类型,如square,前置图标为小方块。还有disc, circle, decimal-leading-zero, decimal, lower-roman, upper-roman, lower-greek, lower-alpha, lower-latin, upper-alpha, upper-latin, Hebrew, Armenian, Georgian, none等等。
<div class="pg47">
	<ul class="pg50">
		<li>list item one</li>
		<li>list item tow</li>
		<li>list item three</li>
		<li>list item four</li>
	</ul>
</div>


ul.pg50 {
	list-style-type : square; /* disc, circle, decimal-leading-zero, decimal, lower-roman, upper-roman, lower-greek, lower-alpha, lower-latin, upper-alpha, upper-latin, Hebrew, Armenian, Georgian, none */
}



图2-12



18. 使用图片作为列表项的前置图标
指定一张图片给列表风格图像list-style-image作为值。
<div class="pg51">
	<ul class="pg52">
		<li>list item one</li>
		<li>list item tow</li>
		<li>list item three</li>
		<li>list item four</li>
	</ul>
</div>

ul.pg52 {
	list-style-image : url(bullet.gif);
}



图2-13



19. 移除列表项的左边留白(即移除左边的缩进)
把列表风格类型(指前置图标)设置为none,再把左边的margin和padding设置为0值。
<div class="pg52">
	<ul class="pg53">
		<li>list item one</li>
		<li>list item tow</li>
		<li>list item three</li>
		<li>list item four</li>
	</ul>
</div>


ul.pg53 {
	list-style-type : none;
	padding-left : 0;
	margin-left : 0;
}



图2-14



20. 把列表项显示到同一个水平方向上
设置display属性值为inline可以把列表项都显示到水平方向上。
<div class="pg54">
	<ul class="pg54horix">
		<li>list item one</li>
		<li>list item tow</li>
		<li>list item three</li>
		<li>list item four</li>
	</ul>
</div>



ul.pg54horix li{
	display : inline;
}



图2-15



(第二章 · 完)
分享到:
评论

相关推荐

    THE CSS3 ANTHOLOGY 4th

    《THE CSS3 ANTHOLOGY:第四版》是由Rachel Andrew所著的一本全面介绍CSS3技术的图书。本书第四版更新于2012年3月,专注于讲解CSS3的最新特性与应用,旨在帮助读者将其网站设计提升至一个新高度。Rachel Andrew作为...

    [The.CSS3.Anthology(4th,2012)].Rachel.Andrew.文字版.pdf )

    2. **第2章:文本样式和其他基础** - **文本样式**:探讨如何使用CSS来控制文本的字体、大小、颜色等属性。 - **段落样式**:介绍如何使用CSS来设置段落的对齐方式、行高、缩进等。 - **列表样式**:教授如何使用...

    The CSS Anthology: 101 Essential Tips, Tricks & Hacks, 3rd Edition

    The CSS Anthology: 101 Essential Tips, Tricks & Hacks is a compilation of best practice solutions to the most challenging CSS problems. The third edition of this best-selling book, published in full ...

    (英文)The CSS Anthology: 101 Essential Tips, Tricks & Hacks 2009

    2. **Text Styling and Other Basics** - 文本样式和其他基础知识 - 字体、颜色和大小的控制方法。 - 如何设置文本对齐、行高和间距。 - 使用伪类和伪元素来增强文本效果。 3. **CSS and Images** - CSS与图像 ...

    The JavaScript Anthology.pdf

    本章提供了JavaScript中日期对象的全面介绍,包括日期格式化和时区转换。 #### 10. 处理图像 图像在网页中起着重要作用。本章讨论了如何使用JavaScript加载、显示和操作图像,以及如何创建动态图像效果。 #### 11...

    The.JavaScript.Anthology.101.Essential.Tips.Tricks.Hacks

    2. **DOM操作**:DOM(Document Object Model)是网页内容的结构化表示,JavaScript通过DOM API可以访问和修改网页元素。书中将详细讲解如何选择、创建、修改和删除DOM节点,以及如何利用事件监听来实现交互效果。 ...

    Sitepoint.The.WordPress.Anthology

    - **知识点简介**:本章主要介绍WordPress的基础概念及环境搭建过程。 - **核心内容**: - 安装与配置WordPress的基本步骤; - 创建第一个WordPress站点; - 理解WordPress后台管理界面的基本操作。 - **第2章...

    HTML-CSS开发工具.pdf

    12. **CSS框架和设计模式**:如《CSS Anthology》、《O'Reilly CSS: The Definitive Guide》等,这些书籍提供了CSS的最佳实践和常见设计模式,帮助开发者写出更高效、可维护的CSS代码。 综上所述,HTML和CSS开发...

    CSS设计大师设计思路与实践(第二版)

    第二版的内容可能涵盖了CSS2.1及CSS3的新特性,如媒体查询、 Flexbox和Grid布局系统,这些对于响应式设计至关重要。 书中可能详细介绍了以下知识点: 1. **基础概念**:CSS的基本语法、选择器、属性和值,包括ID...

    The JavaScript Anthology 101 Essential Tips, Tricks

    ### JavaScript Anthology:101 Essential Tips, Tricks & Hacks #### 一、概述 《JavaScript Anthology:101 Essential Tips, Tricks & Hacks》是一本由James Edwards和Cameron Adams编写的经典JavaScript教程...

    The WordPress Anthology.pdf

    The WordPress Anthology puts you in the driver’s seat of this powerful & flexible open-source CMS, offering an extensive array of solutions for your projects. Jam-packed with proven tips & techniques...

    The JavaScript Anthology

    - **Working with Dates and Times(日期与时间处理)**:日期和时间格式化的方法。 - **Detecting Browser Differences(检测浏览器差异)**:如何判断不同浏览器间的差异并作出相应调整。 - **Using JavaScript ...

    The_PHP_Anthology_1_2_incl_code

    第二部分可能涉及更高级的主题: 1. 高级PHP函数和特性:如字符串处理、正则表达式、日期时间处理、文件系统操作等。 2. PHP与数据库交互:深入讲解PDO(PHP Data Objects)和MySQLi扩展,以及如何编写高效的SQL...

    Memory Dump Analysis Anthology ,Volume 2

    《内存转储分析精选集》第二卷不仅为初学者提供了入门知识,还为有经验的读者提供了深入的技术细节。通过阅读本书,读者可以学习到如何有效地分析内存转储文件,解决复杂的技术问题,并提升自己的软件开发和维护技能...

    The ThoughtWorks Anthology-Essays on Software Technology and Innovation.pdf

    ### 《ThoughtWorks Anthology:软件技术与创新论文集》核心知识点提炼 #### 一、概述 《ThoughtWorks Anthology:软件技术与创新论文集》是一本汇集了ThoughtWorks工程师们在软件技术与创新领域多年积累的经验与...

    Memory Dump Analysis Anthology, Volume 3 内存分析技术

    标题和描述中提到的《Memory Dump Analysis Anthology, Volume 3 内存分析技术》是关于内存转储分析的一系列作品中的一卷。这部作品由Dmitry Vostokov编辑,并由Software Diagnostics Institute出版,属于《Memory ...

Global site tag (gtag.js) - Google Analytics