79712216

Date: 2025-07-23 15:56:04
Score: 0.5
Natty:
Report link

Thank you for the outline on how to perform y-direction scrolling ! Thanks to the outline, I was able to perform x-direction scrolling...I thought that I would share it below.

<!DOCTYPE>
<html>
<head></head>
<body>
<div id="div0"></div>
<style>
#div0 { 
  position: absolute; 
  top: 0px; 
  display: flex;
  flex-direction: row;
  height: 100px; 
  max-width: 100px;
  overflow-x: scroll;
  scroll-snap-type: mandatory;
  scroll-snap-points-x: repeat(100px);
  scroll-snap-type: x mandatory;
} 
  
.div_simple_ { 
  position: relative;
  border: 1px solid gray; 
  background-color: seagreen;
  border-radius: 5px; 
  width: 100px;
  scroll-snap-align: start; 
  height: 100px;
  line-height: 100px;
  text-align: center; 
  font-size: 30px;
  flex: 0 0 auto;
}
</style>
<script>
var n = 3;
create_elements();
function create_elements() { 
  
  for (var i=0; i<n; i++) { 
    var divElement = document.createElement("div");
    divElement.setAttribute("id", "div_"+i);
    divElement.setAttribute("class", "div_simple_");
    
    divElement.innerText = i;
    document.getElementById("div0").appendChild(divElement);
  }

} 
</script>
</body>
</html>
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jamilah Foucher