我有一些元素的定位问题,在判断IE8开发工具后,它向我显示了以下内容:

偏移量来自哪里?

现在我很确定我的问题是12的偏移量,但是how do I remove it?我找不到任何关于CSS偏移量属性的内容.除了保证金,我们还需要抵销吗?

下面是产生这种情况的代码:

 <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的元素

推荐答案

该偏移量基本上是浏览器根据元素的position CSS属性计算出的x,y位置.因此,如果您在它或任何其他元素前面加一个<br>,它将更改偏移量.例如,您可以通过以下方式将其设置为0:

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

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

Theref或e, 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.

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

Css相关问答推荐

如何将表格单元格的最后一个子级与单元格底部对齐?

material 设计--Bootstrap输入域问题

我找不出Firefox上奇怪的css行为的原因

CSS关键帧中使用transform-origin存在问题的解决方案

:is() 伪类是否支持相邻sibling 表达式中第二个元素的组合器?

更改 20 个实例中的一个组件的样式

清除 CSS 中已设置的填充属性以恢复 SVG 的默认值

Tailwind css break-word 在输入字段中不起作用

用户代理必须处理(或表现得好像他们这样做)每个链接就好像链接指向单独的样式表这句话是什么意思?

Sass @use 排序

tailwind css 中的自定义组状态

普通流,流布局,块和内联布局有什么区别?

具有自动调整大小的自动填充行的 CSS 网格

在同一旋转中以度数变换旋转

将复选框对齐到中心

如何使半圆的边框淡出?

CSS3 的 :root 伪类和 html 有什么区别?

删除在 ios safari / chrome / firefox 中单击的链接上的灰色背景

如何隐藏 Chrome 中 HTML5
元素上默认显示的箭头?

溢出的文本可以居中吗?