记录一次前端弹窗随窗口缩放位置跑偏问题处理

废话不多说先贴代码

    <el-popover popper-class="my-popper" :visible-arrow="false" placement="bottom" width="240" v-model="userCardPopover" trigger="hover">
          <div class="userCard">
            <div class="border1">
              <div class="border2">
                <el-avatar :size="60" class="avatar-text">{{ nickName.substr(0, 1) || '?' }}</el-avatar>
              </div>
            </div>
            <div class="nick-name">{{ nickName }}</div>
            <div class="user-tel">{{ phone }}</div>
            <div class="party-info" v-if=" platformPartyName!=null && platformPartyName!=''">{{ platformPartyName.length>15?platformPartyName.substring(0,14):platformPartyName}}</div>
            <div class="party-info" v-if=" platformUnitName!=null&& platformUnitName!=''">{{ platformUnitName.length>15?platformUnitName.substring(0,14): platformUnitName}}</div>
          </div>
          <div slot="reference" class="right-menu-item">
            <el-avatar class="avatar-text">{{ nickName.substr(0, 1) || '?' }}</el-avatar>
          </div>
        </el-popover>

在给popper组件设置额外的class,需要使用popper-class

.my-popper {
  padding-bottom: 0 !important;
  position: fixed !important;
  top: 70px !important;
  left: inherit !important;
  right: 5px !important;
}

在这里插入图片描述

开始时设置定位position 为fixed和absoute 然后设置left 发现当窗口非最大化后导致弹窗会超过右侧窗口被遮挡,后设置right,发现并不生效,后通过控制台发现有默认的left 设置,left 优先级要高于right ,所以要先取消掉left在去设置right,当需要固定位置时首要设置定位,在设置其他样式,如不生效控制台查看是否默认样式生效

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值