在线求助:加了position: absolute后图片不再显示。大佬救命

高玩的智熄操作 高玩的智熄操作 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

在网上找了一个瀑布流图片的代码,自己实现了一下

组件部分代码是这样的:

<!--      图片瀑布流-->
      <el-container id="index">
        <!-- 点击图片详情弹窗 --><!-- :open="opmethod" -->
        <el-dialog :visible.sync="dialogVisible" :fullscreen="true" custom-class="el-dialog-aa" top="0"
                   :show-close="false" @open="opmethod">
          <pic-detail ref="detailWin" :picId="picId" @closedialog="closedialog"></pic-detail>
        </el-dialog>
        <!-- 公共搜索头部,管理页面不显示 -->
<!--        <el-header>
          <common-header @clickSearch='search'></common-header>
        </el-header>-->
        <!-- 主体瀑布流区域,无限滚动 -->
        <div class="v-waterfall-content" ref="abc" v-infinite-scroll="getMoreData" infinite-scroll-disabled="disabled"
             infinite-scroll-distance="10" style="overflow:auto">
          <div v-for="img in waterfallList" :key="img.key" class="v-waterfall-item"
               :style="{top:img.top+'px',left:img.left+'px',width:imageWidth+'px',height:img.height}">
            <!-- 图片卡片 -->
            <el-card shadow="hover" :body-style="{'padding':'0px','border-radius':'10px'}" @click.native="openDialog(img.id)">
              <!-- 图片懒加载 -->
              <el-image :src='img.src' class='image' :key='img.src' lazy>
                <!-- 加载前占位 -->
                <div slot="placeholder" class="image-slot">
                  <div :style="{height:img.height+'px',width:imageWidth + 'px',backgroundColor:img.colour}"></div>
                </div>
                <!-- 加载失败占位 -->
                <div slot="error" class="image-slot">
                  <div :style="{height:img.height+'px',width:imageWidth + 'px',backgroundColor:img.colour}"></div>
                </div>
              </el-image>
            </el-card>
          </div>
        </div>
      </el-container>

跑起来是这样的效果,加css之前图片是竖着排的

加入了如下css代码

.v-waterfall-content {
  width: 100%;
  height: 100%;
  position: relative;
}

.v-waterfall-item {
  float: left;
  position: absolute;
}

.v-waterfall-item img {
  width: auto;
  height: auto;
}


.el-card__body .image {
  width: 100%;
  display: block;
}

 再运行项目就不显示图片了:

打开控制台可以是看到每个图片的位置信息的,但不知道为什么不显示

 

把.v-water-fall-item里position:absolute注释掉以后可以显示,但效果也不对,存在大量空白,跟控制台里显示的图片的top值也对不上

 

俺是初学者,求大佬帮帮忙吧~

 

...全文

相关推荐

css position: absolute、relative详解

今天在看CSS的时候遇到了position: absolute、relative的问题,一直比较迷糊,今天终于搞清楚了。

weixin_38501810

position:fixed或absolute时百分比参考屏幕宽度

用百分比设定元素的宽度,一般情况是指参考父元素的宽度,当position是fixed或absolute时,百分比是参考屏幕的宽度

weixin_38704386

详解flex布局与position:absolute/fixed的冲突问题

之前笔者在开发项目的过程中就遇到了这个坑,flex布局与position:absolute/fixed的冲突问题。后来想到了解决办法,今天就与大家一起交流一下: 项目实战: 我们现在想做一个头部的导航栏,又想用fixed把它固定在上方,又想用弹性盒布局去设置它内部的样式,可是发现其中的弹性盒布局已经失效了。 HTML代码如下: 协会简介 协会章程 协会架构 资料下载 CSS代码如下: ul { position: fixed; display: flex;

weixin_38652636

ie6下position:absolute不显示问题解决方法

position:absolute属性在其他浏览器中都是正常的,但惟独在ie6下有问题,下面是经过测试可行的解决方法

weixin_38746951

li标签的position:absolute与relative案例应用

今天在写一个购物车里面选择发货地址的部分时,多个收货地址用到了UL标签,由于每个地址的后面有个“修改地址”的功能,而且位于li标签的右边,于是就用到了,position:absolute; right:10px;这样把“修改地址”移到右边去了,不过在此之前需要在li标签添加position:relative才行。html如下: 复制代码代码如下: <ul class=”addr_list”> <li class=”on”><span>寄送至</span>&lt;input type=”radio” name=”addr” /&gt;廣東省中山市三鄉鎮鴉崗村興隆製衣廠rabbit(rabbit收)1356

weixin_38742124
评论
收藏 已收藏
分享
返回顶部
高玩的智熄操作
CSS 61,116 成员 60,701 内容