亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何以正確的方式對齊我的彈性盒項目?

如何以正確的方式對齊我的彈性盒項目?

動漫人物 2023-11-13 15:23:07
我正在嘗試找出如何對齊我的彈性盒項目。我不確定這是否可能,所以我才問。這是我的代碼:我的CSS:.container {width: 100%; display: flex; position: relative;}.item {display: flex;}.one {width: 65%;}.two {width: 35%;}和html:<div class="container><div class="item one"></div><div class="item one"></div><div class="item one"></div><div class="item two"></div><div class="item two"></div></div>我想讓它像這樣:
查看完整描述

1 回答

?
慕森王

TA貢獻1777條經驗 獲得超3個贊

你想要flex-direction: column和flex-wrap:wrap。然后給你的物品高度,以便它們垂直包裹在容器內:


html,body{height:100%;}


.container {

  display: flex;

  flex-direction: column;

  flex-wrap: wrap;

  border: solid 2px orangered;

  width: 50%;

  height: 60%;

  box-sizing:border-box;

}


.item {

    box-sizing:border-box;

    margin: 2px;

}


.one {

  height: calc(33% - 4px);

  border: solid 2px green;

  width: calc(65% - 4px);

}


.two {

  height: 40%;

  border: solid 2px orange;

  width: calc(35% - 4px);

}

<div class="container">

  <div class=" item one ">one</div>

  <div class="item one ">one</div>

  <div class="item one ">one</div>

  <div class="item two ">two</div>

  <div class="item two ">two</div>

</div>


查看完整回答
反對 回復 2023-11-13
?
倚天杖

TA貢獻1828條經驗 獲得超3個贊

在這里您可以找到 Flexbox 工作原理的快速示例。如果您是初學者,這非常有用。



查看完整回答
反對 回復 2023-11-13
  • 1 回答
  • 0 關注
  • 206 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號