一、背景属性(background-color)
CSS中的background-color属性,用于设置某个元素的背景。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
body
{
background-color: yellow;
}
</style>
</head>
<body>
这个网页背景色为黄色
</body>
</html>
二、颜色属性(color)
CSS中的color属性,用于设置某个元素的文本(字体)颜色。
三、排列属性(text-align)
文本的排列属性是用来设置文本的水平对齐方式。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
#body
{
margin: 0 auto;
width: 80%;
background-color: beige;
}
h1
{
text-align: center;
}
#yi
{
text-align: right;
}
#er
{
background-color: antiquewhite;
width: 50%;
height: 80%;
margin: 0 auto;
text-align: justify;
}
#san
{
text-align: left;
}
</style>
</head>
<body>
<div id="body">
<h1>今日比赛</h1>
<div id="yi">
北京时间4月18日
</div>
<div id="er">
库里轰下47分7篮板,并命中11记三分球,连续10场比赛得分30+,
追平2012年的科比,在历史上33岁或以上球员中并列第一。末节,
库里扭伤脚踝吃止疼药坚持作战。
</div>
<div id="san">
(腾讯体育)
</div>
</div>
</body>
</html>
当text-align设置为“justify”,每一行被展开为宽度相等,左右外边距是对齐。
四、文本修饰(text-decoration)
主要有text-decoration:none; text-decoration:overline; text-decoration:line-through; text-decoration:underline
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
a
{
text-decoration: none;
}
#yi
{
text-decoration: overline;
}
#er
{
text-decoration: line-through;
}
#san
{
text-decoration: underline;
}
</style>
</head>
<body>
<p><a href="#">我是链接</a></p>
<p id="yi">我是文字一</p>
<p id="er">我是文字二</p>
<p id="san">我是文字三</p>
</body>
</html>
五、文本转换(text-transform)
主要是文本中的字母大小写转换
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
#yi
{
text-transform: uppercase;
}
#er
{
text-transform: lowercase;
}
#san
{
text-transform: capitalize;
}
</style>
</head>
<body>
<p id="yi">yellow one mountain</p>
<p id="er">YELLOW ONE MOUNTAIN</p>
<p id="san">yellow one mountain</p>
</body>
</html>
六、文本缩进(text-indent)
指定文本的第一行的缩进
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
#yi
{
width: 80%;
margin: 0 auto;
background-color: antiquewhite;
text-indent: 2rem;
}
</style>
</head>
<body>
<p id="yi">北京时间4月17日,ESPN记者Rachel Richols
对斯蒂芬-库里进行了专访。在谈到续约问题时,库里表示他
会优先考虑留在勇士。库里暗示他想要成为科比、诺维茨基那样的球员。
库里说道:“一直留在一支球队,这是我优先考虑的事情。你
可以看看像德克(诺维茨基)、科比(布莱恩特)这样的家伙,
我曾和他们对抗过,外界对他们的评价很高。他们对自己的球队表示出了一种敬意。
“你永远不知道未来会发生什么。但我感觉,对我来说那意味着很多。
当然,你也希望保持竞争力,想要待在你曾夺得总冠军的球队。如果
我二者可以兼得的话,那就是我的最终目标了。”
</p>
</body>
</html>
七、文本字体系列属性(font-family)
八、文本字体大小属性(font-size)
九、文本字体粗细属性(font-weight)
十、文本字体样式属性(font-style)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
.normal
{
font-style: normal;
}
.italic
{
font-style: italic;
}
.oblique
{
font-style: oblique;
}
</style>
</head>
<body>
<p class="normal">我是正常字体</p>
<p class="italic">我是斜体</p>
<p class="oblique">我也是斜体,但一般不支持这种写法</p>
</body>
</html>
十一、行高属性(line-height)
用于指定文本中一行的高度,常用百分比的值来设置,如:
`line-height:150%`,表示文本行间距为当前字符尺寸的1.5倍