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. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. css - 寫頁面遇到個布局問題,求大佬們幫解答,在線等,急!~4. 實現bing搜索工具urlAPI提交5. javascript - nodejs關于進程間發送句柄的一點疑問6. javascript - vue-router 地址改變數據未改變7. 配置Apache時,添加對PHP的支持時語法錯誤8. phpstudy8.1支持win11系統嗎?9. javascript - 移動端上不能實現拖拽布局嗎?10. javascript - html5多個label中其中一個觸發change,如何判斷是哪一個出發了change

網公網安備