吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1774|回复: 5
收起左侧

[求助] CSS Flex布局堆叠的问题

[复制链接]
cqwcns 发表于 2020-6-2 21:24
最近在玩小程序,使用Flxe布局时,各个view的宽度是一致的,但高度不一致,这样同一行的两个view高度不同时,会留空。
我不希望它留空,而是全部堆叠起来,不留空,要怎么实现,谢谢。
06-02 212337.png

[HTML] 纯文本查看 复制代码
<!--pages/test/test.wxml-->
<view class="viewContent">
<view class="viewA">A</view>
<view class="viewB">B</view>
<view class="viewC">C</view>
<view class="viewD">D</view>
<view class="viewE">E</view>
</view>


[CSS] 纯文本查看 复制代码
/* pages/test/test.wxss */
.viewContent{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.viewA{
  background-color: aqua;
  width: 50%;
  height: 100px;
}

.viewB{
  background-color: blue;
  width: 50%;
  height: 80px;
}

.viewC{
  background-color: coral;
  width: 50%;
  height:90px;
}

.viewD{
  background-color: darkorange;
  width: 50%;
  height: 120px;
}

.viewE{
  background-color: gray;
  width: 50%;
  height: 100px;
}



发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| cqwcns 发表于 2020-6-2 22:38
查了一下资料,Grid 网格布局(http://www.ruanyifeng.com/blog/2019/03/grid-layout-tutorial.html)应该是可以解决这个问题,但研究了一番,还是没有搞掂,还请各位大哥指教一下。
LXS 发表于 2020-6-2 22:51
pengxl1017 发表于 2020-6-2 23:13
参考css3 columns属性,实现瀑布流
你对块元素的理解不到位
notproblem 发表于 2020-6-3 08:53
[HTML] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <style type="text/css">
        * {margin: 0;padding: 0;}
        .pool {column-count: 2;width: 100%;column-width: auto;font-size: 0;column-gap: 6px;}
        .pool > div {background-color: pink;width: 100%;border: 1px solid red;box-sizing: border-box;
            display: inline-block;margin-bottom: 6px;}
        .h1 {height: 100px;}
        .h2 {height: 80px;}
        .h3 {height: 50px;}
    </style>
</head>
<body>
    <div id="app">
        <div class="pool">
            <div class="h1"></div>
            <div class="h2"></div>
            <div class="h3"></div>
            <div class="h2"></div>
            <div class="h1"></div>
        </div>
    </div>
</body>
</html>

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
cqwcns + 1 + 1 热心回复!

查看全部评分

 楼主| cqwcns 发表于 2020-6-13 22:08
notproblem 发表于 2020-6-3 08:53
[mw_shl_code=html,true]

谢谢,评分送大哥
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-27 03:26

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表