将表格对齐div的最左侧

时间:2011-08-02 07:53:39

标签: html css positioning

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

注意右列的squshed-uppy-ness和左边的间隙。

我也无法修复。

相关的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>

任何帮助表示赞赏

2 个答案:

答案 0 :(得分:2)

由于您的td边框设置为1px,因此会增加我们所看到的总宽度,因此您必须减小td的宽度。见框模型以供参考:

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

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

table{left:-1}

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

答案 1 :(得分:0)

你的事情过于复杂。

http://jsfiddle.net/Z3rs5/

你应该编写简单的代码,也不要把所有的CSS语句都塞进一行,每次你这样做,上帝杀了一只小猫!

相关问题