css - 使用flex怎么实现这种布局?
本文介绍了css - 使用flex怎么实现这种布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
使用flex怎么实现这种布局,我写到第三个写不下去了求大神补充。
<div class="pic">
<div class="pic1"></div>
<div class="pic2"></div>
<div class="pic3"></div>
<div class="pic4"></div>
</div>
<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;*/
}
...
解决方案
大概就像下面这样
<!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>
<div id="main">
<div id="left"></div>
<div id="right-box">
<div id="right-top"></div>
<div id="right-bottom-box">
<div id="bottom-left"></div>
<div id="bottom-right"></div>
</div>
</div>
</div>
</body>
</html>
效果
这篇关于css - 使用flex怎么实现这种布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文