如何使用CSS消除元素的偏移?
I've got a positioning problem with some elements, upon inspecting it IE8 Developer tools it shows me this:
我有一些元素的定位问题,在检查IE8开发工具时它向我展示了:
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?
现在我很确定我的问题是12个偏移量,但是我怎么去掉它呢?我找不到任何CSS偏移属性的提及。除了保证金,我们还需要加减吗?
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>
The element with the offset is inputBox
带有偏移量的元素是inputBox
12 个解决方案
#1
41
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:
这个偏移量基本上是浏览器根据位置css属性计算的元素的x,y位置。如果你把
放在它或任何其他元素之前,它会改变偏移量。例如,你可以将它设置为0 by:
#inputBox{position:absolute;top:0px;left:0px;}
or
或
#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?
你的浏览器不兼容吗?
更多相关文章
- KeyPress或KeyDown事件没有得到html元素的buind
- htmlhref属性最大支持多少个字符???(高分)
- 行内元素与块级元素
- 固定定位,父元素具有转换
- HTML语言中img标签的alt属性和title属性的作用与区别
- 在c#中获取html元素的实际边距
- html中插入activex控件之后 需要在 网页中实现控件的属性及方法,
- 两个堆叠的元素与他们旁边的元素成比例增长
- html css伪元素标签(二)灵活