gilo1212 gilo1212 - 1 month ago 4
jQuery Question

How can I add items down to be able to scroll?

How can I add items down to be able to scroll?




enter image description here

enter image description here

Answer

There is a hack using transform: scaleY(-1) to start adding elements from the bottom

  1. transform: scaleY(-1) on the container to invert it vertically

  2. transform: scaleY(-1) on the children of the container to rectify the inversion on the children.

  3. Even the overflow for the container starts from the bottom!

See demo below:

body {
  margin: 0;
}
* {
  box-sizing: border-box;
}
.wrapper {
  border: 1px solid red;
  height: 100vh;
  overflow-y: auto;
  transform: scaleY(-1);
}
.wrapper > div {
  height: 100px;
  width: 50vh;
  border: 1px solid;
  margin: 10px auto;
  transform: scaleY(-1);
  /*align text inside*/
  display: flex;
  justify-content: center;
  align-items: center;
}
<div class="wrapper">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
</div>

Let me know your feedback on this. Thanks!

Comments