博客列表 >1020作业-box-sizing使用和em案例

1020作业-box-sizing使用和em案例

归宿的博客
归宿的博客原创
2020年10月21日 17:30:52632浏览

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.box {
width: 200px;
height: 200px;
border: 2px solid red;
padding: 20px 30px;
box-sizing: border-box; /border和padding都归为.box所有/
background-image: url(https://img.php.cn/upload/article/000/000/003/5f5add2bab403839.png);
background-position: -100px 100px;
background-clip: content-box; /理解:center-box,也就是只在.box的实际空间里显示/
}
body {
/ 此处的大小是针对全局的,但是优先级比较低 /
font-size: 20px;
}
.em {
width: 10em;
height: 10em;
border: 1px solid green;
margin-top: 100px;
font-size: 1em;
line-height: 10em;
text-align: center;
}
.test {
/ 此处的文字大小是针对此规则集有效,优先级大于body(全局)的文字大小 /
font-size: 16px;
height: 10em;
width: 10em;
border: 1px solid green;
margin: 5em 0;
line-height: 10em;
background-color: violet;
padding: 1em;
/ box-sizing: content-box; /
/ 背景裁剪,只在实际区域显示内容(不含padding区域) /
background-clip: content-box;
}
</style>
</head>
<body>
<div class="box">我是box1</div>
<div class="em">我是em案例</div>
<div class="test">练习</div>
</body>
</html>

html全代码不知道怎么用markdown去编写,老师可以在上课的时候可以讲下

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议