首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的css正在干扰滚动的正常工作。

我的css正在干扰滚动的正常工作。
EN

Stack Overflow用户
提问于 2020-07-03 20:10:49
回答 1查看 51关注 0票数 0

我有这个设置,https://codepen.io/saraLance/pen/LYGevXW和我有一些问题。

  1. header的覆盖范围超过父宽度。
  2. 滚动的工作方式很奇怪,它似乎在按钮play之后停止,然后我不得不再次滚动。

我试图修复滚动问题,使header修复了position: fixed; width: 100%,但是header覆盖的范围比父div更多。

我也不知道为什么screen高度和它的父screens不一样。

理想情况下,sit-container应该是在header之后,header应该是固定的。

代码语言:javascript
复制
div {
  width: auto;
}

.screens {
  background: green;
  height: 100vh;
  display: flex;
  overflow-x: hidden;
  overflow-y: auto;
}

.screen {
  background: red;
}

.header {
  border: solid 1px black;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-evenly;
  padding: 12px;
  background: white;
}

.sit-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1rem;
  overflow: auto;
}

.strip {
  width: 100vw;
}

.view {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 300px;
  min-width: 300px;
  animation-delay: 0.2s;
  overflow-y: scroll;
  flex-direction: column;
}

.view-1 {
  height: 300px;
  width: 300px;
  flex: 0 0 auto;
  margin: 0 auto;
  margin-top: 1rem;
  border: solid 1px black;
}

.button-section {
  display: flex;
  flex-direction: column;
  text-align: center;
  margin-top: 1rem;
  width: 100%;
}

.play-button {
  height: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
  color: black;
  border: 1px solid black;
  text-decoration: none;
  padding: 1rem 1.25rem;
  line-height: 1rem;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-style: normal;
  font-weight: normal;
  text-align: center;
  text-transform: uppercase;
  margin: 1rem;
}

.quit-button {
  color: black;
  text-decoration: none;
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid black;
}
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=">
  <title></title>
</head>

<body>

  <div class="screens">
    <div class="screen">
      <div class="header">
        <div class="div-1">Div-1</div>
        <div class="div-1">Div-2</div>
      </div>
      <div class="sit-container">
        <div class="strip">
          <div class="view">
            <div class="view-1">View-1</div>
            <div class="view-1">View-2</div>
            <div class="view-1">View-3</div>
            <div class="view-1">View-4</div>
          </div>
        </div>
        <div class="button-section">
          <a class="play-button">Play</a>
          <a class="quit-button">Quit</a>
        </div>
      </div>
    </div>
  </div>
</body>

</html>

EN

回答 1

Stack Overflow用户

发布于 2020-07-04 04:47:08

screens类应该是width: autooverflow-x:hidden应该在button-section

见全屏输出

代码语言:javascript
复制
div {
  width: auto;
}

@media (min-width: 768px) {
  width:35%;
  margin:auto;
}

.screens {
  background: green;
  height:"auto";
  display: flex;
}

.screen {
  background: red;
}

.header {
  border: solid 1px black;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-evenly;
  padding: 12px;
  background: white;
}

.sit-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1rem;
  overflow: auto;
}

.strip {
  width: 100vw;
  @media (min-width: 768px) {
    width: 35vw;
  }
}

.view {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 300px;
  min-width: 300px;
  animation-delay: 0.2s;
  overflow-y: scroll;
  flex-direction: column;
}

.view-1{
  height: 300px;
  width: 300px;
  flex: 0 0 auto;
  margin: 0 auto;
  margin-top: 1rem;
  border: solid 1px black;
}

.button-section{  
  display: flex;
  flex-direction: column;
  text-align: center;
  margin-top: 1rem;
  width: 100%;
  overflow-x:hidden;
}

.play-button {
  height: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
  color: black;
  border: 1px solid black;
  text-decoration: none;
  padding: 1rem 1.25rem;
  line-height: 1rem;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-style: normal;
  font-weight: normal;
  text-align: center;
  text-transform: uppercase;
  margin: 1rem;
}

.quit-button {
  color: black;
  text-decoration: none;
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid black;
}
代码语言:javascript
复制
<div class="screens">
  <div class="screen">
    <div class="header">
      <div class="div-1">Div-1</div>
      <div class="div-1">Div-2</div>
    </div>
    <div class="sit-container">
      <div class="strip">
        <div class="view">
          <div class="view-1">View-1</div>
          <div class="view-1">View-2</div>
          <div class="view-1">View-3</div>
          <div class="view-1">View-4</div>
        </div>
      </div>
      <div class="button-section">
        <a class="play-button">Play</a>
        <a class="quit-button">Quit</a>
      </div>
    </div>
  </div>
</div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62722121

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档