可滚动的静态块一

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

Scrollable blocks in static one

问题

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

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

  1. .parent {
  2. position: fixed;
  3. overflow: hidden;
  4. left: 0;
  5. top: 50px;
  6. width: 100%;
  7. height: calc(100% - 50px);
  8. }
  9. .child {
  10. overflow: scroll;
  11. }
  1. <div class="parent">
  2. <div class="child">
  3. *内容*
  4. </div>
  5. <div class="child">
  6. *内容*
  7. </div>
  8. </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 -->

  1. .parent {
  2. position: fixed;
  3. overflow: hidden;
  4. left: 0;
  5. top: 50px;
  6. width: 100%;
  7. height: calc(100% - 50px);
  8. }
  9. .child {
  10. overflow: scroll
  11. }

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

  1. &lt;div class=&quot;parent&quot;&gt;
  2. &lt;div class=&quot;child&quot;&gt;
  3. *content*
  4. &lt;/div&gt;
  5. &lt;div class=&quot;child&quot;&gt;
  6. *content*
  7. &lt;/div&gt;
  8. &lt;/div&gt;

<!-- end snippet -->

答案1

得分: 1

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

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

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

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

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:

确定