在视口(viewport)达到最大宽度后,我在正确对齐浏览器右侧的 div 时遇到问题。
问题 div 是 .rghtlogo,当浏览器视口(viewport)小于 1200px(正文最大宽度)时正确定位为 right:4%
但是,当浏览器视口(viewport)大于 1200 像素时,它会将边距推到主体容器内部右边缘的 4%,而不是浏览器。
我尝试将它包装在一个绝对定位的 div 中,但没有成功,尝试 float .rghtlogo 没有成功,并且基本上已经诉诸了一个非常草率的不受欢迎的解决方法,使用多个媒体查询来基本上随着浏览器变大而改变边距。然而,这个 Action 并不流畅。
@media (min-width:1201px){.rghtlogo{margin-right:3% !important}}
@media (min-width:1216px){.rghtlogo{margin-right:1.5% !important}}
@media (min-width:1230px){.rghtlogo{margin-right:.75% !important}}
@media (min-width:1251px){.rghtlogo{margin-right:0% !important}}
@media (min-width:1256px){.rghtlogo{margin-right:-1% !important}}
我已经搜索过如何解决这个问题,但无济于事。非常感谢任何帮助。
最佳答案
将.rghthdr
中的position:fixed
改为position:relative
并将.rghtlogo
中的top
和right
分别修改为-250px
和0
。
因此 .rghtlogo
始终相对于 .rghthdr
定位。
请参阅此更新的代码笔:http://codepen.io/yogeshkhatri/pen/NPKQZg
关于javascript - 最大宽度正在改变位置 :fixed margin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26880219/