How to hide scroll-view scroll bar in applet

There are still a lot of pits in the applet. In the past few days, either stepped on the pit or on the way to step on the pit? This is not the problem that the scroll bar of scroll-view cannot be hidden.

I have repeatedly checked the scroll-view document and the scroll bar properties are not hidden. It is also very helpless. What can I do? Do it yourself

::-webkit-scrollbar {
    width: 0;
    height: 0;
    color: transparent;
}

A familiar solution, but not a familiar taste!

WTF! Doesn't support such writing? ? ?

Don't be afraid, I am definitely not the first person to encounter this pit. Let us see what good colleagues can do?

I didn’t find any good solutions. Finally, I saw a good solution in a post on the official WeChat community. The post address

 I wonder if you understand? It doesn’t matter if I don’t understand it, I use my excellent (bad) drawing ability to make a picture for everyone to understand. The method provided by the official staff above is a scroll-view for vertical scrolling, but my actual needs are Horizontal scrolling, so the following figure is also for horizontal scroll-view.

The outer box of the scroll-view needs to be higher than the scroll-view by at least the height of the scroll bar, and then the box overflow: hidden. This method does not remove the scroll bar but makes the user invisible. It is really clever~

I tried it with joy and found that it still didn't work! I was so happy, and the hope I just saw was shattered again.

But we can't give up. Persistence is one of the outstanding characteristics of me. This way of thinking seems to be okay, but why not? What went wrong, after thinking about it, is it this padding? Isn't it necessary to reserve space for the scroll bar? But this padding blocked the reserved space again.

Which of our great scientists said (Which one is here?) Without experimentation, there is no right to speak. Let's remove padding and try it, eh, that's it!

The code is gone. Everyone’s business needs are different. I just hope that friends who stepped on the same pit can save some time to find information?

 

Guess you like

Origin blog.csdn.net/promiseCao/article/details/88572772