在小米官网上找到网页的一部分先来看一下(如下图)
就像上面这样的一个简单网页布局,用简单的HTML+css就能实现
主要运用的技术就是"盒子模型的浮动"
浮动是什么?
- 浮动主要的作用有两个 图文环绕和网页布局
- 浮动特点:脱离标准流 比标准流高半个级别
浮动元素会受到上边元素边界的影响
使不能设置宽高的元素 可以设置宽高(例如span标签)
代码如下
<!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> * { margin: 0; padding: 0; } .bigbox { width: 1226px; height: 614px; margin: 100px auto; /* background-color: pink; */ } .leftbig { width: 234px; height: 614px; background-color: #800080; margin-right: 14px; /* display: inline-block; */ float: left; } .o1 { width: 234px; height: 300px; background-color: #87ceeb; float: left; margin-right: 14px; margin-bottom: 14px; } .o2 { width: 234px; height: 300px; background-color: #87ceeb; float: left; margin-right: 14px; margin-bottom: 14px; } .o3 { width: 234px; height: 300px; background-color: #87ceeb; float: left; margin-right: 14px; margin-bottom: 14px; } .o4 { width: 234px; height: 300px; background-color: #87ceeb; float: left; margin-bottom: 14px; } .o5 { width: 234px; height: 300px; background-color: #87ceeb; float: left; margin-right: 14px; } .o6 { width: 234px; height: 300px; background-color: #87ceeb; float: left; margin-right: 14px; } .o7 { width: 234px; height: 300px; background-color: #87ceeb; float: left; margin-right: 14px; } .o8 { width: 234px; height: 300px; background-color: #87ceeb; float: left; } </style> </head> <body> <div class="bigbox"> <div class="leftbig"></div> <div class="o1"></div> <div class="o2"></div> <div class="o3"></div> <div class="o4"></div> <div class="o5"></div> <div class="o6"></div> <div class="o7"></div> <div class="o8"></div> </div> </body> </html>
实现的效果:
这个代码只是给了一个框架哦,要是具体实现的话,需要把背景颜色去掉换成对应的图片就好啦,后期会给大家写一篇具体板块的博文哦~这样就能简单的实现这个网页的展示啦~
喜欢或者对你有用的话就给小高点个赞吧!卑微小码农在线求赞~