首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HTML中的不同Windows

问HTML中的不同Windows
EN

Stack Overflow用户
提问于 2020-07-22 17:59:06
回答 2查看 89关注 0票数 0

在创建一个网站时,我发现浏览别人的网站可以更容易地想象我想要做的事情。我找到了一个网站,它的浏览器窗口的设置方式允许在屏幕上同时出现单独的“窗口”。因此,如果您滚动屏幕的一部分,其余的屏幕将不会这样做,只有部分您滚动。同样地,当您滚动整个屏幕时,有些元素不会与它一起滚动,相反,它们似乎是固定不变的。

我正在寻找的是在我的站点中实现这一点的一种方法--类似于以下“示例”:

代码语言:javascript
复制
[...]
<window position="some-number" size="some-number">
    <!-- not a real element -->
    [...]
</window>
[...]

有什么一般的方法吗?你必须在JavaScript中对这种行为进行编程吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-07-22 18:31:23

当您滚动元素时,元素留在它们的位置的一种方法是使用position: fixed CSS语句。看这个例子。

​

代码语言:javascript
复制
#notscrolling {
  position: fixed;
  left: 200px;
  top: 10px;
}
代码语言:javascript
复制
<div id="scrolling">
  <p>
    This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will
    scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>This will scroll<br>
  </p>
</div>
<div id="notscrolling">
  <p>this will not scroll</p>
</div>

如您所见,最左边的p滚动,但最右边的p没有。

​

票数 1
EN

Stack Overflow用户

发布于 2020-07-22 18:11:57

这可以通过css样式来实现,比如:将它固定/粘贴到您不想滚动的html元素。

最好的解决方案是使用React,因为React帮助我们创建您自己的自定义组件,这样您就可以像定义上面的用法那样轻松地创建和使用它。

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

https://stackoverflow.com/questions/63040467

复制
相关文章

相似问题

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