gpt4 book ai didi

html - 需要一个表格以适应 div 中的全屏和另一个固定宽度的 div

转载 作者:太空宇宙 更新时间:2023-11-04 05:30:29 24 4
gpt4 key购买 nike

我有以下 HTML。

<body>

<div class="header"></div>

<div class="navdiv"></div>

<div class="mainarea">

<p></p>
<table>
<tr>
<th scope="row">Name</th>
<th scope="row">Description</th>
<th scope="row">Created</th>
<th scope="row">Created By</th>
<th scope="row">Modified</th>
<th scope="row">Modified By</th>
</tr>
</table>

</div>

</body>

我需要 CSS 方面的帮助才能正确构建页面。

我希望标题 100% 横跨顶部,我可以做到。

但我希望“navdiv”在页面左侧固定为 250px。然后使用“mainarea”div 将页面的其余部分带到 navdiv 的右侧。然后我还希望表格横跨页面的其余部分。

我已经尝试了几种变体和一些工作,但是我无法让表格延伸到其余空间,它要么跳到导航下方,超出其他内容太远,要么只调整到内容的大小

有人能帮忙吗?

最佳答案

这应该有效:

.header { width: 100%; }
.navdiv { width: 250px; float: left; height: 400px; background-color: #F00; }
.mainarea { overflow: hidden; position: relative; border: solid 1px #000; }
.mainarea table { width: 100%; border: solid #F00 1px; }
/** hacks for IE6 **/
* html .mainarea { margin-left: 260px; }
* html .mainarea table { float: right; clear: none; }

解释:

我实际上是在使用标准的两栏 overflow: hidden 技巧来强制主要内容保留在其自己的栏中(而不是在导航栏下换行)。主要内容上的position: relative是将其设置为表格的偏移父级,因此我们可以在表格上使用width: 100%将其推到表格的宽度主要区域。

导航的高度、背景颜色和边框仅用于演示目的。

关于黑客:

没有其他(现代)浏览器需要 margin-left: 260px,因为 overflow: hidden 涵盖了这一点(强制将其分为两列)。

仍然,在那个时候,表格似乎清晰到导航的底部(同样,仅在 IE6 中)。这是通过删除任何默认清除(不确定是否有必要)并将其 float 到右侧来解决的,因此它不会考虑导航的大小。

关于html - 需要一个表格以适应 div 中的全屏和另一个固定宽度的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3458636/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com