如何修复IE8中的绝对定位? [英] How to fix Absolute Positioning In IE8?
本文介绍了如何修复IE8中的绝对定位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我使用的每个浏览器中,除了ie8,一个绝对定位的元素可以根据具有相对定位的最近父元素来定位。
In every browser I've used, except ie8, an absolutely positioned element can be positioned according to the closest parent with relative positioning.
divs在表内。顶部div具有position:relative,但是,嵌套的,绝对定位的元素不会遵守其边界(在ie8中,它位于页面底部,而不是父div的底部)。
The below code shows two divs inside a table. The top div has position: relative, however, the nested, absolutely positioned element does not respect its boundaries (in ie8, it gets positioned at the bottom of the page instead of the bottom of the parent div).
有人知道这个修复吗?
<style>
#top {
position: relative;
background-color: #ccc;
}
#position_me {
background-color: green;
position: absolute;
bottom: 0;
}
#bottom {
background-color: blue;
height: 100px;
}
</style>
<table>
<tr>
<td><div id="top"> Div with id="top"
<div id="position_me"> Div with id="position me" </div>
</div>
<div id="bottom"> Div with id="bottom"
<p>Lorem ipsum dolor sit amet.</p>
</div></td>
</tr>
</table>
推荐答案
声明doctype。我建议您使用HTML5 doctype:
Declare a doctype. I'd encourage you to use the HTML5 doctype:
<!DOCTYPE html>
这篇关于如何修复IE8中的绝对定位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文