收藏
回答

movable-view 容器中使用 position: fixed 无法相对屏幕窗口定位?

position: fixed 我理解是相对于窗口定位,但是在movable-view 容器中使用时,其效果则变成了相对 movable-view 容器定位。 并且movable-view相关文档并没有介绍这些,我觉得这是个问题

我期望text-box能定位到屏幕的底部而不是movable-view的底部,这使得我不得不因为样式问题将这个与movable-view中其他内容有关联的text-box移动到外部,并且需要额外维护他们的通信关系。 最主要的原因还是他背叛了position: fixed

代码片段

// index.wxml:
<view class="container">
  <movable-area style="height: 600px; width:300px;border: red solid 1px">
    <movable-view direction="all" style="width: 300px;;height: 300px; background-color: pink;">
      content
      <view class="text-box">
        text-box
      </view>
    </movable-view>
  </movable-area>
</view>

// index.wxss
.text-box{
  width: 100px;
  height: 100px;
  position: fixed;
  bottom: 0;
  background-color: beige;
}

// index.js
const app = getApp()
Page({})


回答关注问题邀请回答
收藏

2 个回答

  • Demons
    Demons
    2022-10-13

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2022-10-13
    有用
    回复 1
  • 他油
    他油
    2023-07-31

    是的,这个问题挺恶心的。position: fixed相对于父级来定位,而无法相对于窗口来定位,跟web表现不一致

    2023-07-31
    有用
    回复
登录 后发表内容