美文网首页
css实现瀑布流

css实现瀑布流

作者: 学无止境_cheer_up | 来源:发表于2023-07-21 22:19 被阅读0次

效果图

image.png

重要属性

最外层盒子
columns: 2;
column-gap: 14px;

如果还想响应式适配,可以配合媒体查询@media(max-width:xxx px){}

子组件DiaryItemComponent --- html

<view class="diary-item-box-container">
        <image class="diary-img" mode="widthFix" :src="diaryInfo.img" />
        <view class="diary-title">{{ diaryInfo.title }}</view>
        <view class="user-info">
            <view class="left">
                <image
                    class="head-img"
                    src="https://ihairpic.yongxianghui.net/front_resource/patientImg/diary-user-headImg-default.png"
                />
                <text class="user-name">{{ diaryInfo.name }}</text>
            </view>
            <view class="right">
                <image
                    class="like-icon"
                    mode="widthFix"
                    src="https://ihairpic.yongxianghui.net/front_resource/patientImg/diary-unlike-icon.png"
                />
                <text class="count">{{ diaryInfo.count }}</text>
            </view>
        </view>
    </view>

子组件DiaryItemComponent ---css

<style lang="scss">
.diary-item-box-container {
    width: 100%;
    background: #ffffff;
    margin-bottom: 16px;
    padding-bottom: 26px;
    break-inside: avoid;

    .diary-img {
        max-width: 100%;
        border-radius: 8px 8px 0px 0px;
    }

    .diary-title {
        font-size: 28px;
        font-weight: bold;
        color: #333333;
        line-height: 40px;
        padding: 0 16px;
        margin-top: 20px;
    }

    .user-info {
        display: flex;
        justify-content: space-between;
        margin-top: 26px;
        padding: 0 16px;
        font-size: 24px;
        color: #666666;

        .left {
            display: flex;
            align-items: center;

            .head-img {
                width: 36px;
                height: 36px;
                border-radius: 50%;
                margin-right: 10px;
            }

            .user-name {
                line-height: 32px;
            }
        }

        .right {
            display: flex;
            align-items: center;

            .like-icon {
                width: 24px;
                height: 22px;
                margin-right: 6px;
            }

            .count {
                line-height: 32px;
            }
        }
    }
}
</style>

父组件html

<view class="diary-main">
            <DiaryItemComponent
                v-for="item in diaryList.filter((_, index) => index % 2 === 0)"
                :key="item.id"
                :diaryInfo="item"
            />
            <DiaryItemComponent
                v-for="item in diaryList.filter((_, index) => index % 2 === 1)"
                :key="item.id"
                :diaryInfo="item"
            />
        </view>

父组件css

.diary-main {
        padding: 24px;
        columns: 2;
        column-gap: 14px;
    }

相关文章

  • css快速实现瀑布流

    css有提供可以实现瀑布流的样式 父盒子设置column-count : 2 列数就可以直接实现瀑布流 ,此时最后...

  • 瀑布流css实现

    父元素设置 flex布局实现父元素:display:flex;横向排列flex-flow:column wrap ...

  • js/jQuery实现瀑布流

    html中主要代码: 实现瀑布流的js代码: css实现瀑布流只需要三行代码: 实现下拉刷新的js代码: js/c...

  • 小程序 瀑布流布局 简单易懂 css 及js 两种方法

    css 自带标签 实现瀑布流 有一定的缺陷 建议使用js...

  • 进阶18 瀑布流

    题目1: 实现一个瀑布流布局效果 html部分 css部分 js部分 瀑布流-demo 题目2 (选做): 根据课...

  • 瀑布流,css3实现和js实现

    Multi-columns方式 纯CSS实现瀑布流要用到Css3多列属性,通过它相关的属性column-count...

  • 7. 多列

    1. 多列的效果 说明:在CSS3中,可以创建多列来对文本或者区域进行布局。 2. 使用多列实现瀑布流效果 瀑布流...

  • 24.纯CSS实现瀑布流布局

    1.CSS实现瀑布流布局(display: flex) 本例使用 CSS flex 实现瀑布流布局关键点,横向fl...

  • css实现图片的瀑布流

    ··· 其中div.masonry是瀑布流的容器, 这个div.column称为列表项目的单独容器,其里面放置了n...

  • 瀑布流布局 的学习

    1- 实现瀑布流布局效果 瀑布流效果瀑布流代码木桶布局效果木桶布局代码瀑布流布局 2- 实现一个新闻瀑布流新闻...

网友评论

      本文标题:css实现瀑布流

      本文链接:https://www.haomeiwen.com/subject/jcotpdtx.html