1、font-size : 用来设置字体大小。
chrome浏览器中,能够显示的最小字体为12px。
2、color : 用来设置字体颜色。
用颜色对应英文单词设置:
color:red;
用颜色对应编码设置也行:
color:#ffffff;
3、width : 设置选择器选中元素的宽度。
width:100px;
4、height : 设置选择器选中元素的高度。
height:100px;
5、background-color : 用来设置背景色。
background-color:red;
background-color:#ffffff;
6、text-align : 设置文本水平居中。
text-align:center;
7、line-height :设置文本垂直居中。
line-height:100px;
8、示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS常用属性</title>
<style>
.test{
/* chrome浏览器:font-size最小值是12px */
font-size: 30px;
/* 字体颜色 */
color: white;
/* 背景色 */
background-color: black;
/* 文本水平居中 */
text-align: center;
/* 文本行高(垂直居中) */
line-height: 40px;
}
img{
width: 300px;
}
</style>
</head>
<body>
<h1 class="test">hello coder</h1>
<img src="E:\mydesktop\tupian\coder.jpg" alt="">
</body>
</html>
浏览器打开: