css - 使用flex怎么实现这种布局?
问题描述
使用flex怎么实现这种布局,我写到第三个写不下去了求大神补充。
<p class='pic'> <p class='pic1'></p> <p class='pic2'></p> <p class='pic3'></p> <p class='pic4'></p></p><style> .pic{display: flex;width: 400px;height: 400px;margin: 100px auto;flex-wrap: wrap; } .pic1{flex: 1;height: 100%;background-color: pink; } .pic2{flex: 1;height: 50%;background: #C81623; } .pic3{/*width: 25%;*//*float: left;*//*height: 50%;*//*background-color: green;*/ } ...
问题解答
回答1:大概就像下面这样
<!DOCTYPE html><html><head> <meta charset='utf-8'> <title></title> <style media='screen'>#main { display: flex; height: 500px;}#left { width: 200px; background: red;}#right-box { display: flex; flex-direction: column; background: blue; flex: 1;}#right-top { height: 200px; background: yellow;}#right-bottom-box { display: flex; flex: 1;}#bottom-left { width: 50%; background: pink;}#bottom-right { width: 50%; background: magenta;} </style></head><body> <p id='main'><p id='left'></p><p id='right-box'> <p id='right-top'></p> <p id='right-bottom-box'><p id='bottom-left'></p><p id='bottom-right'></p> </p></p> </p></body></html>
效果
.flex-box { display: flex;}.flex-1 { flex: 1;}.flex-2 { flex: 2;}.flex-3 { flex: 3;}
<p class='flex-box'> <p class='flex-2'>pic</p> <p class='flex-3'> <p>pic</p> <p class='flex-box'> <p class='flex-1'>pic</p> <p class='flex-1'>pic</p> </p> </p></p>
相关文章:
1. dockerfile - [docker build image失败- npm install]2. css - ul ol前边的标记如何调整样式呢3. golang - 用IDE看docker源码时的小问题4. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!5. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?6. dockerfile - 为什么docker容器启动不了?7. html - 爬虫时出现“DNS lookup failed”,打开网页却没问题,这是什么情况?8. 用CSS3 box-sizing 属性实现两个并排的容器,如果想让容器中间有间隔该如何实现9. css - chrome浏览器input记录上次cookie信息后,有个黄色背景~如何去除!10. mac连接阿里云docker集群,已经卡了2天了,求问?

网公网安备