gpt4 book ai didi

html - 为什么当我应用位置 :fixed to the body? 时窗口不会跳转或滚动

转载 作者:太空宇宙 更新时间:2023-11-03 23:59:53 25 4
gpt4 key购买 nike

<html>
<head>
<style>body{position:fixed}</style>
</head>
<body>
<div style='height:30px;width:3000px'></div>
</body>
</html>

我设置position:fixed到body元素后,窗口不会滚动,为什么?

最佳答案

.element    { position:fixed; top:2%; right:2%;

上面我们将我们的元素从视口(viewport)的顶部和右侧设置为 2%。你可以永远在页面上滚动,但我们的元素仍然会停留在指定的 2% 标记上。您可以在 Facebook 网站(聊天工具栏)上看到有效的固定定位。

或可以引用

http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/

关于html - 为什么当我应用位置 :fixed to the body? 时窗口不会跳转或滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17207727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com