HTML 表格动态重叠父 div
如何在调整大小时使内表与父 div 重叠 5 px?
我当前的解决方案:
<div id="crop">
<table style="width:105%; height:105%;">
//table cells
</table>
</div>
问题是调整大小时它会变小...
我怎样才能使其不断与 5px 重叠;
How can i make the inner table to overlap the parent div with 5 px while resizing?
my current solution:
<div id="crop">
<table style="width:105%; height:105%;">
//table cells
</table>
</div>
problem is that it gets smaller when resizing...
how can I make it constantly overlap with 5px;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下内容似乎在 FF3、Chrome 和 IE7 中运行良好。 尽管在 IE 的 CSS 样式中使用表达式并不理想。
您应该看到,渲染时,蓝色的“外部”div 显示在“内部”div 内。 对于 IE 以外的浏览器,“内部”div 将为红色,而 IE 则为绿色。
另请注意,在本例中,我必须从“内部”div 的高度中减去 2px,以调整顶部和底部边框。
The folling seems to work nicely in FF3, Chrome and IE7. Though using expressions in CSS styles for IE is not ideal.
You should see that when rendered, the blue "outer" div is displayed within the "inner" div. The "inner" div will be red for browsers other than IE where it will be green instead.
Also note, in this example I had to subtract 2px from the height of the "inner" div to adjust for the top and bottom borders.
简而言之:
table
粘贴到另一个div
中,并将table
的宽度设置为 100%div
通过将其定位设置为绝对(确保父级具有相对位置)并将其宽度设置为 100% 来进行移动。div
上使用负边距将其精确拉出 5 像素。这有点混乱,但您肯定需要负边距,并且可能需要
position:absolute
使其重叠...In short:
table
inside anotherdiv
and set thetable
's width to 100%div
do the moving around by setting its positioning to absolute (make sure the parent has relative) and set its width to 100%.div
to pull it out by precisely 5px.It's a bit messy but you'll definitely need negative margins and you'll probably need the
position:absolute
to have it overlapping...您是否尝试过以下操作:
该表格将在右侧和底部与 div 重叠 5px。 添加边距以使表格填满左侧和顶部。 如果您希望整个表格偏移,只需省略边距即可。 您可能需要向表格上方的 div 或内容添加一些样式,以防止 div 折叠。
这是一个完整的示例:
Have you tried the following:
This table will overlap the div with 5px at the right hand side and at the bottom. Margins are added to make the table fill the left hand side and top. Just omit the margins if you want the whole table to offset. You'd probably have to add some style to the div or content above the table, to keep the div from collapsing.
Here's a full example: