JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div class="horizontal-scroll">
<div id="wrap">
<div id="scroll">
<div><!-- Your horizontal content -->
<div class="container-scroll">
<div class="advence-trends_scroll config-content_scroll">
<div class="top_content-scroll">
<img alt="" src="https://www.digi-vet.com/lwv2/img/hdmi.png" />
<h3></h3>
</div>
<div class="content_advence-trends content_style">One of the first monitors in medicine to feature an HDMI port to make connecting to an external display easier.</div>
</div>
<div class="advence-trends_scroll config-content_scroll">
<div class="top_content-scroll">
<img alt="" src="https://www.digi-vet.com/lwv2/img/battery.png" />
<h3></h3>
</div>
<div class="content_external-displays content_style">All units come with a lithium-ion battery which can provide the unit with hours of operation on battery, faster charging time, and longer overall battery life cycle.</div>
</div>
<div class="advence-trends_scroll config-content_scroll">
<div class="top_content-scroll">
<img alt="" src="https://www.digi-vet.com/lwv2/img/alarms.png" style="width:27% ;" />
<h3></h3>
</div>
<div class="content_external-displays content_style">Digicare’s newly engineered smart alarms system helps reduce staff stress by reducing false alarms as well as using a standard alarm tone, LED indicators, and alarm reset features.</div>
</div>
<div class="advence-trends_scroll config-content_scroll">
<div class="top_content-scroll">
<img alt="" src="https://www.digi-vet.com/lwv2/img/tabular.png" style="width:27% ;" />
<h3></h3>
</div>
<div class="content_external-displays content_style">Capable of generating its own digital reports in PDF or Excel Format. Digital reports include Tabular Records, Charts, and ECG waveform recordings.</div>
</div>
<div class="advence-trends_scroll config-content_scroll">
<div class="top_content-scroll">
<img alt="" src="https://www.digi-vet.com/lwv2/img/wireless.png" style="width:27% ;"/>
</div>
<div class="content_easy-touch...
CSS
body{
height: 200vh;
margin-top: 50vh;
}
@media /* horizontal scroll */ {
#scroll::-webkit-scrollbar {
width: 3px;
height: 3px;
}
#scroll::-webkit-scrollbar-track {
background: transparent;
padding: 2px;
}
#scroll::-webkit-scrollbar-thumb {
background-color: transparent;
}
#scroll {
scroll-behavior: smooth;
}
.horizontal-scroll {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: #d6d6d6;
position: sticky;
}
.hide-desktop {
display: none;
}
#wrap {
max-width: 100%;
margin: 80px;
}
#scroll {
overflow-x: scroll;
overflow-y: hidden;
margin: 20px 0;
border-radius: 5px;
text-align: center;
}
#scroll > div:first-child {
height: auto;
width: 1950px;
}
/* content of scroll */
.container-scroll {
display: flex;
flex-direction: row;
align-items: center;
}
.config-content_scroll {
width: 400px;
min-width: 21%;
margin-right: 80px;
margin-left: 50px;
}
.config-content_scroll h3 {
margin: 0;
background-color: #bfbfbf;
border-radius: 100px;
border: 10px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.content_style {
background-color: #c8c8c8;
border-radius: 16px;
height: 20em;
display: flex;
align-items: center;
justify-content: center;
border: 10px solid #bfbfbf;
border-top: 6em solid #bfbfbf;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
color: #000;
padding: 50px;
}
.top_content-scroll {
margin: 0;
background-color: #bfbfbf;
border-radius: 30px;
border: 10px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.top_content-scroll img {
position: relative;
top: 50px;
}
.top_content-scroll h3 {
position:...
JavaScript
let scrollSpeed = 300;
let scroller = document.getElementById("scroll");
scroller.addEventListener("mousewheel", e=>{
// bloquear if e.deltaY==0
if( !e.deltaY ) return;
// setar scrollDirection (-1 = up // 1 = down)
let scrollDirection = (e.deltaY > 0) ? 1 : -1;
// converte pro scroll horizontal
scroller.scrollLeft += scrollSpeed * scrollDirection;
let scrollLeft = Math.round(scroller.scrollLeft);
// calcula o total do scroll
let maxScrollLeft = Math.round( scroller.scrollWidth - scroller.clientWidth );
if(
(scrollDirection === -1 && scrollLeft > 0) ||
(scrollDirection === 1 && scrollLeft < maxScrollLeft )
) e.preventDefault()
// done!
return true;
}, false);