目录
二、font-family (重要, 不过一般仅设置一次)
一、font-size(重要)
二、font-family (重要, 不过一般仅设置一次)
<!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>Document</title>
<link rel="stylesheet" href="./css/base.css">
<style>
</style>
</head>
<body>
</body>
</html>
base.css
body {
font-family: "Microsoft YaHei", "Heiti SC", tahoma, arial, "Hiragino Sans GB", "\5B8B\4F53", sans-serif;
}
三、font-weight(重要)
<!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>Document</title>
<style>
.box {
/* font-weight: bold; */
font-weight: 700;
}
</style>
</head>
<body>
<div class="box">我是div元素</div>
<div>我是div元素</div>
</body>
</html>
四、font-style(一般)
<!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>Document</title>
<style>
.box {
/* 斜体: 字体本身支持斜体时, 显示的斜体 */
/* font-style: italic; */
/* 倾斜: 让文本进行倾斜 */
font-style: oblique;
}
</style>
</head>
<body>
<div class="box">我是div元素</div>
<div>我是div元素</div>
</body>
</html>
五、font-variant(了解)
<!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>Document</title>
<style>
.box {
font-variant: small-caps;
}
</style>
</head>
<body>
<div class="box">My Name Is Coderwhy</div>
</body>
</html>
六、line-height(常用)
<!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>Document</title>
<style>
.box {
background-color: #f00;
color: white;
width: 200px;
line-height: 2;
}
</style>
</head>
<body>
<div class="box">
我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素我是div元素
</div>
</body>
</html>
<!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>Document</title>
<style>
.box {
height: 100px;
background-color: #f00;
color: #fff;
line-height: 100px;
}
</style>
</head>
<body>
<div class="box">我是div元素</div>
</body>
</html>
七、font
<!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>Document</title>
<style>
.box {
/* 关于字体的属性 */
font-size: 30px;
font-weight: 700;
font-variant: small-caps;
font-style: italic;
font-family: serif;
line-height: 30px;
/* 缩写属性 */
/* 1.5的行高是相对于font-size的 */
font: italic small-caps 700 30px/1.5 serif;
}
</style>
</head>
<body>
<div class="box">我是div元素</div>
</body>
</html>