绝对定位在IE中的表单元格内 [英] Absolute Positioning inside a table cell in IE

查看:98
本文介绍了绝对定位在IE中的表单元格内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Internet Explorer中的表格单元格中有一些绝对定位的问题(9具体,但我确定问题存在于< 9)。我试图强迫一个表格单元格内的div占据整个单元格。这在chrome / ff / safari使用很容易:

I'm having some issues with absolute positioning inside a table cell in Internet Explorer (9 specifically, but I'm sure the issue exists in <9 as well). I'm trying to force a div inside a table cell to take up the whole cell. It was pretty easy in chrome/ff/safari using:

div {
    position: absolute;
    top:0;
    bottom:0;
    right:0;
    left:0;
}

td {
    position: relative;
}

但是由于某种原因,IE的行为完全不同。我不能得到它给予div基于表单元格的动态高度。 这里是一个例子来显示我在说什么。它的工作原理我如何需要它在chrome / ff / safari,但它在IE中打破。有什么办法让它在IE中以相同的方式工作吗?谢谢!

But for some reason, IE behaves completely differently. I can't get it to give the div a dynamic height based on the table cell at all. Here's an example to show what I'm talking about. It works how I need it to in chrome/ff/safari, but it's broken in IE. Is there any way to get it to work the same way in IE? Thanks!

推荐答案

我建议您不要将元素定位到所有方向,只使用其中两个,您的div。

I recommend you instead of positioning your element to all directions, use only two of them and instead, use size for your div.

like:

div {
    position: absolute;
    top:0;
    bottom:0;
    width: 100%;
    height: 100%
}

td {
    position: relative;
    width: 400px;
    height: 400px;
}

这篇关于绝对定位在IE中的表单元格内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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