微信小程序SCROLL-VIEW橫向滾動顯示不全,及子元素縱向排列問題

一句話,scroll-view的子元素要inline-block,父元素white-space: nowrap;就可以橫向排列。但是這個時候,子元素有最后一個元素有可能是顯示不全的,需要在scroll-view加上overflow: scroll;。就可以完美解決問題,直接上代碼吧。本人親自踩此坑,如有幫助,請點贊哦,好用不點贊就是耍流氓,哈哈,白嫖。

<view class="title-con">
            <view class="conclude-title">已選</view>
            <scroll-view class="scroll-view_H" scroll-x="true">
                <block wx:for="{{selectedStrategy}}" wx:key="strategy_id">
                    <view class="filter-item">
                        <!-- <text>{{item.strategy_name}}</text> -->
                        {{item.strategy_name}}
                        <image src="/images/close.png" class="close" bindtap="handleCloseStrategy" data-catid="{{item.strategy_cat_id}}" data-strategyid="{{item.strategy_id}}" />
                    </view>
                </block>
            </scroll-view>
        </view>



.title-con {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    height: 62rpx;
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow: visible;
    white-space: nowrap;
}

.scroll-view_H {
    width: 100%;
    overflow: scroll;
}

.filter-item {
    padding-left: 28rpx;
    padding-right: 28rpx;
    line-height: 62rpx;
    background: rgba(237, 249, 249, 1);
    border-radius: 40rpx;
    text-align: center;
    margin-right: 18rpx;
    color: rgba(55, 194, 188, 1);
    display: inline-block;
}


?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容