1.

 

边框
border:3px dotted;
border: 2px solid yellow; 背景颜色
background-color: red; 外攘
margin:20px 0 20px 0; 内推
padding-left: 20px; 宽高
width:128px;
height: 64px;
#背景图案
background: url('images/rose.png');
background-size:contain;
background-size: 150px 150px; #自定义 #盒子模型
box-sizing: border-box; #相对定位
position: relative;
left:64px;
top:64px; #绝对定位
父级必须是定位:
.bg{
position: absolute;
} .yellow-flower{
position: absolute;
left:128px;
top:128px;
} #居中
position: absolute;
left:50%;
top:50%;
transform: translate(-50%,-50%); 准星修改
transform: translate(-50%,-50%);

 2.练习

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>css总结</title>
<link rel="stylesheet" href="css/semantics.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css.css" media="screen" title="no title" charset="utf-8">
</head>
<body> <div class="block-1">
1111
</div> <div class="block-2">
222
</div> <div class="block-3">
333
</div>
</body>
</html>
.block-1{
border: 2px solid yellow;
background-color: pink;
margin:20px 0 20px 0;
padding-left: 20px;
width:64px;
height: 64px;
} .block-2{
border:3px dotted;
border: 2px solid yellow;
background-color: red;
margin:20px 0 20px 0;
padding-left: 20px;
width:128px;
height: 64px;
} .block-3{
border: 2px solid ;
background-color: rgb(57, 241, 160);
margin:20px 0 20px 0;
padding-left: 20px;
width:256px;
height: 64px; }

3.box-sizing: border-box;的作用

.block-1{
  box-sizing: border-box;
}

4.最终版本:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>css总结</title>
<link rel="stylesheet" href="css/semantics.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css.css" media="screen" title="no title" charset="utf-8">
</head>
<body > <div class="bg"> <div class="flower">
<div class="point"> </div>
</div> <div class="block-1">
1111
</div> <div class="block-2">
222
</div> <div class="yellow-flower">
<div class="point"> </div>
</div> <div class="block-3">
333
</div> </div> </body>
</html>
body{
margin: 0;
background: url('images/brick.jpg');
background-size: 150px 150px;
} .bg{
border: 8px solid rgb(77, 217, 27);
background-color: blue;
width: 300px;
height: 300px;
position: absolute;
left:50%;
top:50%;
transform: translate(-50%,-50%); } .block-1{
box-sizing: border-box;
padding-left: 20px;
width: 64px;
height: 64px;
background: url('images/grass.png');
background-size: contain;
} .block-2{
box-sizing: border-box;
padding-left: 20px;
width:128px;
height: 64px;
background: url('images/grass.png');
background-size: contain;
} .block-3{
box-sizing: border-box;
padding-left: 20px;
width:256px;
height: 64px;
background: url('images/grass.png');
background-size: contain;
} .yellow-flower{
width: 64px;
height: 64px;
background: url('images/flower.png');
background-size:contain;
position: absolute;
left:128px;
top:128px;
}
.flower{
width: 64px;
height: 64px;
background: url('images/rose.png');
background-size:contain;
position: relative;
left:64px;
top:64px;
} .point{
width: 8px;
height: 8px;
background-color: rgb(240, 120, 22);
}

最新文章

  1. git安装及命令使用和github网站
  2. commonjs AMD,CMD
  3. 为七牛云存储开发的PHP PEAR 包:Services_Qiniu
  4. git tag之后如何修改
  5. Python调试工具-Spyder
  6. python时间函数
  7. js 与 ios Android交互
  8. JAVA_SE基础——54.异常
  9. jna调用c++的dll
  10. java Calendar 入门【转】
  11. From传值
  12. sql server 游标的简单用法
  13. hdfs fsimage namenode 应该设置多少堆内存合适
  14. [译] Go 并发编程基础
  15. python __setattr__和__getattr__
  16. Material Design系列第二篇——Getting Started
  17. JavaScript 累加求和练习
  18. jQuery选择器this通过onclick传入方法以及Jquery中的this与$(this)初探,this传处变量等
  19. mysql常用函数示例
  20. mongoDB GUI客户端工具大全

热门文章

  1. Java—包装类、Date和SimpleDateFormat、Calendar类
  2. Tomcat 中部署 web 应用 ---- Dubbo 服务消费者 Web 应用 war 包的部署
  3. Eclipse: 导入项目乱码问题解决
  4. April 9 2017 Week 15 Sunday
  5. ffmpeg 安装和参数介绍
  6. HTML?这些还不懂咋办?
  7. Installing xgboost and cmake, mingw64 and mingw
  8. 打表格,字符串处理,POJ(2136)
  9. object dection资源
  10. td过长,将固定宽度table撑开