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. 我的html頁面一提交,網頁便顯示出了我的php代碼,求問是什么原因?2. java 排序的問題3. tp6表單令牌4. angular.js - Angular路由和express路由的組合使用問題5. docker 17.03 怎么配置 registry mirror ?6. node.js - node 客戶端socket一直報錯Error: read ECONNRESET,用php的socket沒問題哈。。7. 網絡傳輸協議 - 以下三種下載方式有什么不同?如何用python模擬下載器下載?8. 我在centos容器里安裝docker,也就是在容器里安裝容器,報錯了?9. 數據庫 - 使用讀寫分離后, MySQL主從復制延遲會導致讀不到數據嗎?10. django - 后臺返回的json數據經過Base64加密,獲取時用python如何解密~!
