如何使用CSS去除元素的偏移量? [英] How do I get rid of an element's offset using CSS?

查看:200
本文介绍了如何使用CSS去除元素的偏移量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些元素的定位问题,在检查它IE8开发工具它显示我这样:

I've got a positioning problem with some elements, upon inspecting it IE8 Developer tools it shows me this:

现在我很确定我的问题是12偏移,但如何删除它?我找不到任何提到的CSS偏移属性。除了保证金之外,我们还需要一个抵消额?

Now I'm pretty sure my problem is that 12 offset, but how do I remove it? I can't find any mention of a CSS offset property. Do we need an Offset in addition to margin?

以下是生成此保证金的代码:

Here is the code thats producing this:

 <div id="wahoo" style="border: solid 1px black; height:100px;">

    <asp:TextBox ID="inputBox" runat="server" />

    <input id="btnDropDown" type="button" style="width:26px; height:26px; background-position: center center; border-left-color: buttonface; background-image: url(Images/WebResource.gif); border-bottom-color: buttonface; border-top-color: buttonface; background-repeat: no-repeat; border-right-color: buttonface;"  tabindex="99" />

    <div id="ListboxWrapper" style="display:none; position:absolute; onfocusout="this.style.display = 'none'"">
       <asp:ListBox ID="lstBoxCompany" runat="server" AutoPostBack="True" OnSelectedIndexChanged="lstBoxCompany_SelectedIndexChanged" style="z-index: 100;" Width="300px" />               
    </div>

</div>

具有偏移量的元素为 inputBox

推荐答案

偏移基本上是浏览器根据其位置css属性为元素计算的x,y位置。因此,如果你在它或任何其他元素之前放置一个< br> ,它会改变偏移量。例如,您可以将它设置为0:

That offset is basically the x,y position that the browser has calculated for the element based on it's position css attribute. So if you put a <br> before it or any other element, it would change the offset. For example, you could set it to 0 by:

#inputBox{position:absolute;top:0px;left:0px;}

#inputBox{position:relative;top:-12px;left:-2px;}

因此,无论你有什么定位问题,都不一定是偏移的问题,虽然你可以通过使用顶,左,右和底属性来解决它。

Therefore, whatever positioning issue you have, is not necessarily an issue with offset, though you could always fix it by playing with the top,left,right and bottom attributes.

您的问题是浏览器不兼容吗?

Is your problem browser incompatibility?

这篇关于如何使用CSS去除元素的偏移量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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