m***@163.com
m***@163.com
  • 发布:2025-11-03 18:43
  • 更新:2025-11-04 15:00
  • 阅读:69

uni-app x,Android端子元素设置position:fixed;父盒子位置提到顶部,这是bug还是Android端的特性

分类:uni-app x
<template>  
    <view class="body">  
        <view class="feedback">  
            <view class="type uni-row">  
                <view class="form-title uni-row">  
                    <text class="label">反馈类型</text><text class="require">*</text>  
                </view>  
                <view class="select uni-row">  
                    <text class="select-text">selectType</text>  
                    <!-- <image class="right" src="/static/image/common/mipmap-hdpi/right.png" mode="widthFix"></image> -->  
                </view>  
            </view>  
            <view class="content">  
                <view class="form-title uni-row">  
                    <text class="label">反馈内容</text><text class="require">*</text>  
                </view>  
                <view class="textarea">  
                    <textarea class="text" placeholder="请描述您要反馈的问题" placeholder-class="placeholder"></textarea>  
                </view>  
            </view>  
        </view>  
        <view class="fixed">  
            <view class="footer">  
                <text class="btn">提交</text>  
            </view>  
        </view>  
    </view>  
</template>  

<style lang="scss">  
    .body {  
        flex: 1;  
        background: #F6F7F8;  

        .fixed {  
            width: 750rpx;  
            height: 104rpx;  
            background: green;  

            .footer {  
                position: fixed;  
                bottom: 0;  
                left: 0;  
                width: 750rpx;  
                height: 104rpx;  
                background: blue;  

                .btn {  
                    margin: 12rpx 30rpx;  
                    width: 690rpx;  
                    height: 80rpx;  
                    background: #FF718D;  
                    border-radius: 40rpx 40rpx 40rpx 40rpx;  
                    text-align: center;  
                    line-height: 80rpx;  
                    font-family: Source Han Sans CN, Source Han Sans CN;  
                    font-weight: 400;  
                    font-size: 34rpx;  
                    color: #FFFFFF;  
                }  
            }  
        }  
    }  
</style>

以上例子中fixed盒子的子元素footer设置了position: fixed;fixed盒子应该跟在feedback盒子下面,但实际上fixed盒子跑到页面顶端了,如图

2025-11-03 18:43 负责人:无 分享
已邀请:
DCloud_UNI_OttoJi

DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信

你提供的代码不全,不能直接运行,我编辑了你提供改动代码片段,你复制重新执行一下,看表现和 web 平台并无差异。如果你认为是 bug,请修改我提供的代码,或者提供完整复现工程

  • m***@163.com (作者)

    找到原因了,是全局css内有个fixed设置了position: fixed;导致的样式冲突

    2025-11-04 17:09

  • DCloud_UNI_OttoJi

    回复 m***@163.com: 好的,有问题再反馈

    2025-11-04 17:34

要回复问题请先登录注册