可滚动的静态块一

huangapple go评论75阅读模式
英文:

Scrollable blocks in static one

问题

我有一个静态的不可滚动的登录页面,其中包含可滚动的卡片。我将overflow: hidden;属性添加到父元素,将overflow: scroll;属性添加到子元素,但这些块仍然不移动。也许你知道我错在哪里?

我希望.child块在.parent块保持静态的同时可以滚动。

.parent {
  position: fixed;
  overflow: hidden;
  left: 0;
  top: 50px;
  width: 100%;
  height: calc(100% - 50px);
}

.child {
  overflow: scroll;
}
<div class="parent">
  <div class="child">
    *内容*
  </div>
  
  <div class="child">
    *内容*
  </div>
</div>
英文:

I have a static non-scrollable landing page and to scrollable cards in it. I add property overflow: hidden; to parent and overflow: scroll; to child, but these blocks still don't moving. Maybe you know where am I wrong?

I want to .child blocks be scrollable while .parent block is static.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.parent {
  position: fixed;
  overflow: hidden;
  left: 0;
  top: 50px;
  width: 100%;
  height: calc(100% - 50px);
}

.child {
  overflow: scroll
}

<!-- language: lang-html -->

&lt;div class=&quot;parent&quot;&gt;
  &lt;div class=&quot;child&quot;&gt;
    *content*
  &lt;/div&gt;
  
  &lt;div class=&quot;child&quot;&gt;
    *content*
  &lt;/div&gt;
&lt;/div&gt;

<!-- end snippet -->

答案1

得分: 1

你正在朝着正确的方向前进。只需为子元素设置一个特定的高度并放置内容,以便可以滚动。

.child {
    overflow: scroll;
    height: 100px; 
    /* 在标有"*content*"的位置放置任何固定高度的内容 */
}
英文:

You are going to the right direction. Just set a specific height to the child and put content so that you can scroll.

.child {
    overflow: scroll;
    height: 100px; 
    /*Put any fixed height you want and put content where it is written &quot;*content*&quot; */
}

huangapple
  • 本文由 发表于 2023年6月22日 03:10:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526430.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定