css 瀑布流布局_CSS-瀑布流布局

e3ddac54eafc930f7c2121d6bb7773be.png

参考:

1、column-count 把div中的文本分为多少列

2、column-width 规定列宽

3、column-gap 规定列间隙

4、break-inside: avoid; 避免元素内部断行并产生新列

111
222

/*大层*/

.box {

margin: 0 auto;

width: 100%;

column-count: 2;

column-width: 334px;

column-gap: 20px;

}

.item{

margin-bottom: 10px;

break-inside: avoid; /* 防止多列布局,分页媒体和多区域上下文中的意外中断 */

}

.box{

display: flex;

flex-direction: row;

margin: 0 auto;

width: 100%;

}

.col{

margin-right: 20px;

flex-direction: column;

width: 334px;

}

.item {

background:#fff;

margin-bottom:20px;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现CSS瀑布流布局的两列效果,可以通过以下步骤进行操作: 1. 使用弹性盒子(flexbox)布局。将父容器(container)设置为弹性盒子,设置其flex-direction属性为column,这样子元素会按列排列。 2. 指定每个子元素(item)的宽度为50%(或是其他任意所需的宽度),这样就可以实现两列布局。 3. 根据需求,可以对子元素进行其他样式的调整,比如给图片设置宽度为100%等。 以下是示例代码: ```css .container{ display: flex; flex-direction: column; } .item{ width: 50%; } .item img{ width: 100%; } ``` 通过以上步骤,你可以实现CSS瀑布流布局的两列效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [CSS3不规则瀑布流布局特效](https://download.csdn.net/download/weixin_38665668/16319388)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [CSS总结——瀑布流布局](https://blog.csdn.net/m0_67401660/article/details/126099099)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值