【问题标题】:Responsive horizontal fullscreen scrolling of divs响应式水平全屏滚动 div
【发布时间】:2019-04-30 13:26:04
【问题描述】:

我正在寻找为特定项目添加非 JS CSS3 动画的解决方案。

这个动画应该自动开始,每隔 10 秒滚动(水平)到下一页。

<table style="width:100%">
  <tr>
    <th>First</th>
    <th>Second</th> 
    <th>Third</th>
  </tr>
  <tr>
    <td>A</td>
    <td>B</td> 
    <td>C</td>
  </tr>
  <tr>
    <td>D</td>
    <td>E</td> 
    <td>F</td>
  </tr>
</table>

假设我们有三个页面包含此内容。 什么是我的问题的合适解决方案?

【问题讨论】:

标签: css css-transitions css-animations


【解决方案1】:

您可以使用margin-left 滚动。但为此,我相信您可能需要更改您的 html。

请看下面的片段:

.page-container{
  animation: scroll 8s 2s infinite linear forwards;
  width:2000px;
}

.page {
  width:650px;
  height:200px;
  color:white;
  font-family:calibri;
  text-align:center;
  vertical-align:middle;
  line-height:60px;
  display:inline-block;
}
.one{
  background: #3A4662;
}

.two{
  background: #00827F;
}

.three{
  background: #580137;
}


@-webkit-keyframes scroll {
  10% {
    margin-left: 0px;
  }
  35%{
    margin-left: -650px;
  }
  50%{
    margin-left: -650px;
  }
  75%{
    margin-left: -1300px;
  }
  90%{
    margin-left: -1300px;
  }
  95%{
    margin-left:0px;
  }
  100% {
    margin-left: 0px;
  }
}
<div class="page-container">
  <div class="page one">
    <div>First</div>
    <div>A</div>
    <div>D</div>
  </div>
  <div class="page two">
    <div>Second</div> 
    <div>B</div> 
    <div>E</div> 
  </div>
  <div class="page three">
    <div>Third</div>
    <div>C</div>
    <div>F</div>
  </div>
</div>

你也可以测试一下here

【讨论】:

  • 这是垂直的,op 说是水平的 :) 使用 margin-left 也许 :D 但你需要以不同的方式定位它们
  • 谢谢,太棒了 - 我会根据你的提示尝试类似的东西来实现水平滚动。
  • Opps,我以为我读过 Vertical 所以做了它.. 会做出改变
  • 更新了答案.. ;) 很快
  • 谢谢,真的很棒。你知道如何让这个无限吗?从第三页后的第一页开始
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-09-20
  • 2014-09-07
  • 1970-01-01
  • 1970-01-01
  • 2021-12-30
  • 1970-01-01
  • 2013-07-09
相关资源
最近更新 更多