html - 将表格对齐到 div 的最左侧

标签 html css positioning

我正在尝试制作一个 2x2 网格,它用一张 table 填满 iPhone 的整个窗口。 目前它看起来像这样:http://dl.dropbox.com/u/182509/photo.PNG

请注意右列的压扁和左侧的间隙。

我也无法修复。

相关CSS:

body { margin: 0; position: absolute; height: 100%; }

.full { position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; background-color: white; }

table { border-width: 0px; border-spacing: 0px; border-style: hidden; border-color: gray; border-collapse: collapse; background-color: white; width: 100%; height: 100%; left: 0; top: 0px; margin: 0; padding: 0px; position: absolute; }

td { border-width: 1px; padding: 1px; border-style: solid; border-color: gray; background-color: white; width: 50%; height: 160px; }

和 html:

<div id="helpView" class="full">
    <table id="help">
        <tr>
            <td>Hey..</td>
            <td>Hi.</td>
        </tr>
        <tr>
            <td>Hello.</td>
            <td>Greetings!</td>
        </tr>
    </table>
</div>

感谢任何帮助

最佳答案

由于您的 td 将边框设置为 1px,它增加了我们所看到的总宽度,因此您必须减小 td 的宽度。引用框模型:

http://www.w3.org/TR/CSS2/box.html

或者您可以将表格的 left 设置为 -1 以将其调整到左侧:

table{left:-1}

它将起作用,因为位置是绝对的。

关于html - 将表格对齐到 div 的最左侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6908843/

相关文章:

javascript - onClick 函数删除 :hover pseudo class

php - 索引页脚很古怪

html - 元素的定位

javascript - 第二次单击后无法动态设置单选按钮值

javascript - 使用 z-index 在父 <div class> 上方显示 <ul class>?

css - 定位 div,使其看起来像选项卡

html - 如何删除 HTML/CSS 中段落下的多余空间

jquery - 无法居中淡入淡出图像 (jQuery)

javascript - 为什么关键帧动画没有按预期发生

javascript - 如何使我的 Canvas 外菜单滚动?