CSS字体属性定义字体,加粗,大小,文字样式
color
div{ color:red;}
div{ color:#ff0000;}
div{ color:rgb(255,0,0);}
div{ color:rgba(255,0,0,.5);}
font-size
设置文本的大小能否管理文字的大小,在网页设计中是非常重要的。但是,你不能 通过调整字体大小使段落看上去像标题,或者使标题看上去像段 落。
h1 {font-size:40px;}
h2 {font-size:30px;}
p {font-size:14px;}
font-weight
H1 {font-weight:normal;}
div{font-weight:bold;}
p{font-weight:900;}
font-style
背景属性
background-color属性
<div class="box"></div>
.box{
width: 300px;
height: 300px;
background-color: palevioletred;
}
background-image属性
设置元素的背景图像 元素的背景是元素的总大小,包括填充和边界(不包括外边距)。 默认情况下background-image属性放置在元素的左上角,如果图 像不够大的话会在垂直和水平方向平铺图像,如果图像大小超过元 素大小从图像的左上角显示元素大小的那部分
<div class="box"></div>
.box{
width: 600px;
height: 600px;
background-image: url("images/img1.jpg");
}
background-repeat属性
.box{
width: 600px;
height: 600px;
background-color: #fcc;
background-image: url("images/img1.jpg");
background-repeat: no-repeat;
}
.box{
width: 600px;
height: 600px;
background-image: url("images/img1.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
}
.box{
width: 600px;
height: 600px;
background-color: #fcc;
background-image: url("images/img1.jpg");
background-repeat: no-repeat;
background-position: center;
}
background-attachment属性
该属性设置背景图像是否固定或者随页面滚动。简单来说就是一个 页面有滚动条的话,滑动滚动条背景是固定的还是随页面滑动的
background属性
background 简写属性在一个声明中设置所有的背景属性 background-image、background-repeat、background-position 其中background-size单独书写
text-align
h1 {text-align:center}
h2 {text-align:left}
h3 {text-align:right}