小编use*_*800的帖子

调整浏览器大小时绝对位置错误

我有两个divs ,第一个div位于相对位置,另一个div位于绝对位置,当我将浏览器大小调整为 100% 屏幕尺寸时,一切看起来都很好。

\n\n

当我调整浏览器大小并且绝对位置的第二个元素出现在容器之外时,问题就出现了,虽然不多,但仍然处于外部的不同位置。

\n\n

演示: http: //jsfiddle.net/1pde2gyc/

\n\n

我的CSS代码:

\n\n
#container_front {\n    position:relative;\n    width:40%;\n    margin-left:auto;\n    margin-right:auto;\n}\n\n#front_like {\n    position:absolute;\n    width:50px;\n    height:50px;\n    left:75%;\n    bottom:-1%;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

问题是front_like,这个 DIV 内部有一个图像,该图像或多或少显示在右侧和中间,当我将屏幕大小调整到 50 或 30% 时,图像会从名为 的容器中消失container_front

\n\n

我认为使用绝对和 % 总是保持在相同的位置,但我看到当调整大小移出时,是否存在解决此问题的解决方案?ir css计算位置并留在容器中的同一侧并且没有出去

\n\n

谢谢\xc2\xb4s最诚挚的问候。

\n

html css css-position css-float

0
推荐指数
1
解决办法
9679
查看次数

标签 统计

css ×1

css-float ×1

css-position ×1

html ×1