穿透设置第三方组件的class相关疑问

穿透设置第三方组件的class相关疑问

<template>

    <div class="icons">

      <swiper>

          <swiper-slide>

            <div class="icon"  v-for="item of iconList" :key="item.id">

                <div class="icon-img">

                    <img class="icon-imgcontent" :src="item.imgUrl">

                </div>

                <p class="icon-title">{{item.desc}}</p>

            </div>

         </swiper-slide>

      </swiper>

    </div> 

</template>


<script>

export default {

  name: 'HomeIcons',

  data() {

      return {

          iconList:[{

              id:'0001',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点"

          },{

              id:'0002',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点2"

          },{

              id:'0003',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点3"

          },{

              id:'0004',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点"

          },{

              id:'0005',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点2"

          },{

              id:'0006',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点3"

          },{

              id:'0007',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点"

          },{

              id:'0008',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点2"

          },{

              id:'0009',

              imgUrl:'http://img1.qunarzz.com/piao/fusion/1611/54/ace00878a52d9702.png',

              desc:"热门景点3"

          }]

      }

  },

}

</script>


<style lang="stylus" scoped>

  @import '~styles/varibles.styl'

  .icons >>> .swiper-container

    display flex

    flex-wrap wrap

    height 0

    padding-bottom 50%

    .icon

      overflow hidden

      width 25%

      height 0

      padding-bottom 25%

      position relative

      .icon-img

        box-sizing border-box

        position absolute

        top 0

        right 0

        left 0

        bottom .44rem

        overflow hidden

        box-sizing border-box

        padding .15rem .3rem

        .icon-imgcontent

          width 100%

          height 100%

      .icon-title

       position absolute

       bottom 0

       right 0

       left 0

       height .44rem

       line-height .44rem

       text-align center

       color $darkTextColor

  .icons >>> .swiper-container

    height 0

    padding-bottom 50%   

</style>

老师,本来我对.icon 用这个flex属性布局里面的icon图标 display flex、flex-wrap wrap,没有用老师的float left 布局;现在因为要穿透设置.swiper-container的属性,.swiper-container设置display flex、flex-wrap wrap这些是无效的吗?我icon图标都是一列展示了


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕码 2020-09-30 15:07:37

同学你好,没错儿,是这样的。祝学习愉快~

好帮手慕码 2020-09-30 10:43:26

同学你好,swiper-container设置了flex布局之后,(二者中间还有很多层div)无法直接作用于icon,建议修改如下:

http://img1.sycdn.imooc.com//climg/5f73f08e098346ac04230170.jpg

http://img1.sycdn.imooc.com//climg/5f73f09a0934a4d905300303.jpg

效果:

http://img1.sycdn.imooc.com//climg/5f73f0a209a8749904360244.jpg

如果我的回答帮到了你,欢迎采纳,祝学习愉快~

  • 提问者 慕仰5025445 #1
    老师,是不是这种穿透设置已有class属性的,要先了解内容样式原理,然后再看设置什么属性合适?
    2020-09-30 11:12:14
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师