P粉0605283262023-09-01 14:46:59
Just add this CSS code 'white-space:nowrap;' in the container DIV.
<div style="width:100%;height:300px;background-color: coral;overflow-y: scroll;font-size:0px;white-space:nowrap; ">
P粉1564156962023-09-01 10:50:41
I found the solution:
<style> /* webkit, per chrome, edge, safari */ ::-webkit-scrollbar { height: 12px; width: 5px; background: #aaa; } ::-webkit-scrollbar-thumb { background: #393812; -webkit-border-radius: 1ex; -webkit-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.75); } ::-webkit-scrollbar-corner { background: #000; } /* per firefox */ .custom-scrollbar { scrollbar-width: thin; scrollbar-color: #393812 #aaa; } .container { width: 100%; height: 300px; border: 1px solid green; overflow-x: scroll; overflow-y: hidden; font-size:0px; } .inner { height: 100%; white-space:nowrap; } .floatLeft { width: 150px; margin:0px; display: inline-block; } button { height: 94px; width: 150px; margin: 0px; border: solid 1px gray; } </style> <div class="container custom-scrollbar"> <div class="inner"> <div class="floatLeft"> <div> <button>Cap1</button> </div> <div> <button>Cap2</button> </div> <div> <button>Cap3</button> </div> </div> <div class="floatLeft"> <div> <button>Cap1</button> </div> <div> <button>Cap2</button> </div> <div> <button>Cap3</button> </div> </div> <div class="floatLeft"> <div> <button>Cap1</button> </div> <div> <button>Cap2</button> </div> <div> <button>Cap3</button> </div> </div> <div class="floatLeft"> <div> <button>Cap1</button> </div> <div> <button>Cap2</button> </div> <div> <button>Cap3</button> </div> </div> <div class="floatLeft"> <div> <button>Cap1</button> </div> <div> <button>Cap2</button> </div> <div> <button>Cap3</button> </div> </div> <div class="floatLeft"> <div> <button>Cap1</button> </div> <div> <button>Cap2</button> </div> <div> <button>Cap3</button> </div> </div> </div> </div>