html - float 表固定/相对位置的问题

标签 html css

我有一个页面,里面有 3 个表,其中一个是从服务器数据生成的,可以有任意数量的行。其他 2 个表格用于 float 在顶部并显示始终可见的按钮和表格标题。这是一些代码:

<table style=" position:absolute, top: 110px; z-indez:1; width:100%;">
  <tr>
    <td>
      <table>
        <tr>
          <td> Cart </td>
          <td> Quantity </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<table style="margin-top:60px; height:auto; width:100%;">
@foreach (var item in Model) {
<tr>
    <td>
        @Html.Partial("MoreInformation", item)
     </td>
</tr>
}   
</table>

<table style="position:absolute; bottom:100px; height:70px; width:100%;">
    <tr>
        <td>
            <table>
                <tr>
                    <td style="text-align:left;">
                        <button type="button" onclick="window.location.href='/Home/Index'">Go Home</button>
                    </td>
                    </tr>
            </table>
        </td>
    </tr>
</table>

这个设置有问题: 我在左侧有一个菜单。当我折叠它时,带有 MoreInformation 的表很顺利,但其他 2 个表保持固定在它们的位置上。 如何使“ float 在顶部”的表格与数据表格一起移动(带有更多信息的表格?

附言我曾尝试将 2 个表放在一个 div 中,使该 div position:fixed 并将表放在 position:relative 中,但它不起作用。

最佳答案

<table style=" position:absolute, top: 110px; z-indez:1; width:100%;">
<tr>
        <td>
            <table align="left">
                <tr>
                    <td style="text-align:left;">
                        <button type="button" onclick="window.location.href='/Home/Index'">Go Home</button>
                    </td>
                    </tr>
            </table>
        </td>
    </tr>
  <tr>
    <td>
      <table>
        <tr>
          <td> Cart </td>
          <td> Quantity </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<table style="margin-top:60px; height:auto; width:100%;">
@foreach (var item in Model) {
<tr>
    <td>
        @Html.Partial("MoreInformation", item)
     </td>
</tr>
}   
</table>

关于html - float 表固定/相对位置的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31423818/

相关文章:

html - lang=unknown 属性是否有效?

html - 覆盖内联CSS?

jquery - 循环滚动网站

html - 在 JSP 表单中使用 Web 模板

html - 等待获取数据时显示加载屏幕

javascript - 获取 html 错误 301,返回完全相同的链接

c# - 对于 : Razor with Javascript method inside tbody

css - Bootstrap 导航栏在 IE8 中不可见

css - 在其他元素居中时将文本设置为左侧 - CSS - Bootstrap 4

javascript - 如何 : Center Horizontal Menu & SubMenu