您的位置:首页 > Web前端 > CSS

CSS学习:文本排版,颜色,背景,边框,边距

2009-09-22 16:09 573 查看
文本的精细排版:
调整字符间距: letter-spacing: normal | 长度
调整单词间距: word-spacing: normal | 长度
添加文字修饰: text-decoration: underline | overline | line-through | blink | none
设置文本排列方式: text-align: left | right | center | justify(两段对齐)
设置段落缩进: text-indent: 长度 | 百分比
调整行高: line-height: normal | 数字 | 长度 | 百分比
转换英文大小写: text-transform: uppercase | lowercase | capitalize(单词首字母大写) | none

颜色和背景:
网页中的每一个元素都有一个前景色和一个后景色, 而且前景色和后景色最好同时设置, 以免重复或冲突.
设置颜色: color:颜色
color属性不是只用来设置字体的颜色, 网页中每个元素的颜色都可以用color属性来设置, color属性设置的颜色一般都为标记内容的前景色.
设置背景颜色: background-color: 颜色 | transparent(透明值)
在CSS中使用background-color属性不仅可以设置网页的背景颜色, 还可以设置文字的背景颜色
插入背景图片: background-image: url | none

Code
<html>
<head>
<title>设置颜色和背景</title>
<style type=text/css>
<!--
body{background-image:url(14-7-1.jpg);background-repeat:no-repeat;
background-position:bottom right}
h2{font-family:黑体;color:white;font-size:20px;background-image:url(14-7-2.jpg);
background-repeat:repeat-x}
.p1{font-size:18px;color:blue;background-color:yellow;}
-->
</style>
</head>
<body>
<center>
<h2>黄鹤楼</h2>
<hr>
<p class=p1>昔人已乘黄鹤去,此地空余黄鹤楼。</p>
<p class=p1>黄鹤一去不复返,白云千载空悠悠。</p>
<p class=p1>晴川历历汉阳树,芳草萋萋鹦鹉洲。</p>
<p class=p1>日暮乡关何处是,烟波江上使人愁。</p>
</center>
</body>
</html>
边框和边距:
边框属性包括边框样式, 边框颜色, 边框宽度, 主要用来设置网页中各个元素的边框, 如段落, 图片, 表格等

设计边框样式: boder-style
border-style:样式取值
border-top-style:样式取值
border-bottom-style:样式取值
border-left-style:样式取值
border-right-style:样式取值
调整边框宽度: border-width
border-width:关键字 | 长度
border-top-width:关键字 | 长度
border-bottom-width:关键字 | 长度
border-right-width:关键字 | 长度
border-left-width:关键字 | 长度
设置边框颜色 border-color
设置边框属性: border 同时设置边框的宽度,样式和颜色
border: 边框宽度 | 边框样式 | 边框颜色
border-top:
border-bottom:
border-right:
border-left:

边距: margin-top / margin-bottom / margin-right / margin-left / margin
用来设置网页中某个元素的四边和网页中其他元素之间的空白距离.
填充: padding-top / padding-bottom / padding-right / padding-left / padding
用来控制边框和其他元素之间的空白距离, 和边距属性很类似.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐