html - CSS 位置 : table and div inside div

标签 html css

我被一个简单的 css 问题困在这里:

问题是在右下角的 div 元素内对齐“World”文本。

这是一个 fiddle : http://fiddle.jshell.net/0p6w3x14/2/

<div id="container">
<div id="tableElement">
    <table> <!-- this table needs to be here, it's containing more info -->
        <tr>
            <td>
                 Hello
            </td>
        </tr>
    </table>
</div>
    <div id="element">
        World
    </div>

</div>

#container
{
width: 200px;
border: 1px solid black;  
}

#tableElement
{
border: 1px solid black;
display: inline-block;
}

table
{
    border: 1px solid red;
    height: 100px;
}

#element
{
    display: inline-block;
    float: right;
border: 1px solid green;
}

最佳答案

像这样更新你的 CSS:

#container
{
width: 200px;
border: 1px solid black;  
    position:relative; // add this line
}

#element
{
    display: inline-block;
    position:absolute; //add this line
    bottom:0; //add this line
    right:0; //add this line
   border: 1px solid green;
}

并移除float:right

Working fiddle here

关于html - CSS 位置 : table and div inside div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26628834/

相关文章:

html - CSS 中同一个 li 标签有 2 个位置

html - 传单 - map "shadowed",当大小设置为百分比时不可点击

javascript - 如何在单色 React 中制作渐变背景?

css - 如何设置 canvas 元素的后备内容的样式?

jquery - 为用户选项创建菜单

css - 试图并排获得三个部门

Javascript 字符串替换没有效果

html - 居中 <UL> + 保持 <LI> 对齐

html - 将页脚置于窗口或页面底部,以较大者为准

css - 根据 Session 更改按钮类