简体   繁体   English

位置绝对+ <body> 位置相对

[英]position absolute + <body> position relative

Im redesigning a vary old page. 我正在重新设计一个不同的旧页面。 In order to make the menu system work, they use position: relative; 为了使菜单系统工作,他们使用position:relative; on the <body> tag. <body>标签上。 My problem is that when I for example create a jQuery ui datepicker or something that is positioned absolute, it gets shown +- ~200px to left/right. 我的问题是,当我例如创建一个jQuery ui datepicker或者位于绝对位置的东西时,它会向左/右显示+ - 〜200px。 Is there any workaround to this? 这有什么解决方法吗? Thanks 谢谢

在整个页面周围创建一个容器<div> ,并将其设置为position: relative

I know it is a very old post but if this helps anyone else out there, this problem might be occurring due to the margin on the left side of the body. 我知道这是一个非常古老的帖子,但如果这有助于其他人,那么由于身体左侧的边缘可能会出现这个问题。

A simple fix could be to counter the margin before the datepicker shows up. 一个简单的解决方法是在datepicker出现之前对抗边距。

$('#container').datepicker(
{
    beforeShow: function(inputElem, dp)
    {
        dp.dpDiv.css({ marginLeft: '-' + $('body').css('margin-left') });
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM