当滚动条存在时,绝对div移位 [英] Absolute div shifts when scrollbar is present

查看:267
本文介绍了当滚动条存在时,绝对div移位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我的页面的整个内容有一个问题。

问题是没有滚动条,我的内容在右边大约20px,但是当滚动条存在时,它向左移动。
我必须补偿这一绝对位置div通过将它的内容放置20px直到滚动条存在,因为它在页面的右侧。

i have a problem with the entire content of my page.
The problem being without a scrollbar present my content is about 20px to the right, but when a scrollbar is present it shifts to the left. I have to compensate for this for an absolute postioned div by positioning it over the content by 20px until a scrollbar is present as it rests at the right hand side of the page.

这是一个肮脏的错误代表我,但我只是想要一个简单的方法来解决这个问题。任何快速和容易的建议?

This is a crappy fault on my behalf but i just want an easy way to fix this. Any quick and easy suggestions? Would i be better off making the main content div an absolute one?

推荐答案

一个快速和肮脏的方式是总是强制滚动条可以显示:

One quick and dirty way is to always force the scrollbar to be visible with:

html {overflow-y:scroll; }

html { overflow-y: scroll; }

不太理想,但如果缺少滚动条偏移会破坏您的设计,它会使外观标准化。

Not ideal, but it standardizes the appearance if the lack of scrollbar offset is breaking your design.

这篇关于当滚动条存在时,绝对div移位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆