html - 如何在div的底部设置表格

标签 html css

我需要我的表格在我的 div 的底部对齐,我尝试将属性添加到表格的样式中:position:absolute;bottom:0px 但它根据页面和不是股利。我发布了完整的代码(带有 img 标签),因为我不确定其他标签的影响。

//HTML

 <div>
            <img src="Img/flower" style="width: 960px; height: 474px; z-index: -1; position: absolute" />
            <table style="width:100%;height:120px;">
                  <tr>
            <td style="background-color:gray">
            </td>
             <td style="background-color:green">
            </td>
             <td style="background-color:yellow">
            </td>
             <td style="background-color:red">
            </td>
             <td style="background-color:lime">
            </td>
             <td style="background-color:maroon">
            </td>
        </tr>
            </table></div>

最佳答案

Your parent "div" and "img" should be declared as "position:relative" in this case. here is your solution:

<div style="position: relative;">
            <img src="Img/flower" style="width: 960px; height: 474px; z-index: -1; position: relative;">
            <table style="width: 100%; height: 120px;">
                  <tbody><tr>
            <td style="background-color:gray">
            </td>
             <td style="background-color:green">
            </td>
             <td style="background-color:yellow">
            </td>
             <td style="background-color:red">
            </td>
             <td style="background-color:lime">
            </td>
             <td style="background-color:maroon">
            </td>
        </tr>
            </tbody></table>


</div>

关于html - 如何在div的底部设置表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35635643/

相关文章:

javascript - 如何将元素放入另一个元素(jQuery)?

html - 页脚在 Opera (11.63) 中消失

javascript - 从 HTML/Javascript 关闭 iPad Web 应用程序?

javascript - 正则表达式以像素为单位转换所有 rem-calc

html - float 在 <figure> 和 <figcaption> 行中

javascript - 正则表达式 - 如何在不在 html 内部时替换 css

jquery - 选择 ul 中的最后一个 li

php - MySQL 更新大量 html 内容问题

html - 将样式内联更改为 css

html - CSS 动画 : after completing first animation set display block at start of second animation WITHOUT JAVASCRIPT