html - 如何向下添加元素以便能够滚动?

标签 html css flexbox css-transforms

如何向下添加元素以便能够滚动?


enter image description here

enter image description here

最佳答案

有一个 hack 使用 transform: scaleY(-1) 从底部开始添加元素

  1. transform: scaleY(-1) 在容器上垂直反转

  2. transform: scaleY(-1) 对容器的 child 纠正对 child 的反转。

  3. 容器的溢出也是从底部开始的!

请看下面的演示:

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>

让我知道您对此的反馈。谢谢!

关于html - 如何向下添加元素以便能够滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40143821/

相关文章:

html - 在 Flex 元素列中,将最后两个元素放在一行中

c++ - C++ 应用程序的外部 Web 界面

javascript - 将 URL 重定向到 div 标签

css - 使用 Bootstrap3 固定侧边栏设置宽度

javascript - 在状态变化时 react 内联样式

html - 无论高度如何,始终在图像中心放置文本

css - 如何使输入组填充水平空间?

javascript - 根据指定元素长度创建新 div 的最佳方法?

javascript - 更改 CKEditor 表单元素的 HTML(在对话窗口中)

html - 为什么div不调整大小?