I'm currently working on my own small program project. Because it is not a professional front end. So I fell into a pit with every step. I would like to summarize the problems I encountered here. Avoid repeating the pit. question:When I was laying out the mini-program page, I used the scroll-view component, but found that horizontal movement had no effect. I looked up some information online and found the problem. My wxml code <scroll-view scroll-x="true" class="scroll" bindscrolltolower="lower" bindscroll="scroll"> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> <view class="user_info"> <view class="user_head"> <image src="../../icon/head.jpg"></image> </view> <view class="username">Zhang San</view> </view> </scroll-view> wxss code .enroll_view .scroll_view .scroll{ height:160rpx; width:750rpx; overflow: hidden; } .user_info{ float:left; margin-top:10rpx; height:140rpx; width:140rpx; } The idea is very simple. I want to use float:left; to arrange the elements that need to slide horizontally. After consulting the information, I found that elements that need to slide cannot use float. To achieve this effect, you need to use display:inline-block;. Continue to modify (delete float:left; and use display:inline-block; to achieve the effect of horizontal arrangement of sub-elements) wxss style .user_info{ margin-top:10rpx; height:140rpx; width:140rpx; display: inline-block; } After making changes, you find that it still doesn’t work. And it was found that the line was wrapped after the subset element exceeded the width. So add white-space: nowrap; to scroll-view to prevent its internal elements from wrapping. refresh. Achieve the final effect. Kaisen. Rendering Final version wxss .enroll_view .scroll_view .scroll{ height:160rpx; width:750rpx; overflow: hidden; white-space: nowrap; } .user_info{ margin-top:10rpx; height:140rpx; width:140rpx; display: inline-block; } Knot1. The elements that need to slide in the scroll-view cannot be floated to achieve the horizontal arrangement effect. You can use display:inline-block; to change them to inline block elements; 2. Using display:flex; on a large box in scroll-view that contains elements that need to slide has no effect; 3. The large box that wraps the scroll-view has a clear width and style white-space:nowrap; Attached are the main properties of scroll-view: SummarizeThis is the end of this article about how to solve the problem that the scroll-view of WeChat mini-program cannot slide left and right. For more relevant content about the scroll-view of WeChat mini-program sliding left and right, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Linux common basic commands and usage
>>: Installation and configuration tutorial of MySQL 8.0.16 under Win10
There is no data directory, my-default.ini and my...
Table of contents 1. Demand Method 1 Method 2 Met...
Table of contents Table/index.js Table/model/inde...
This article shares the specific code for Vue to ...
Effect: The title has its own serial number, the ...
Recently, the server has been frequently cracked ...
First, understand a method: Entering a Docker con...
Many friends who have just started to make web pag...
CSS writing order 1. Position attributes (positio...
Table of contents Preface 1. Trigger Overview 2. ...
Table of contents Rendering Install Code Implemen...
Table of contents Preface 1. Recursive components...
Table of contents 1. What is a closure? 2. The ro...
CentOS official website address https://www.cento...
Table of contents 1. Constructors and instances 2...