Axel Richter: Abstand zwischen td-rand und table-rand

Beitrag lesen

Hallo,

ich möchte den abstand vom oberen rand einer td zum rand der tabelle ändern.
also wie mit border-spacing nur bei einer seite (->margin-top).

mit margin funktioniert es aber nicht.wenn ich es bei der table-class einfüge nimmt er es als abstand vom bildschirmrand zur tabelle und bei der td-class ignoriert es es obwohl keine feste breite oder höhe eingestellt ist.

Dafür ist nach CSS2 border-spacing vorgesehen. Der MSIE5.x kann das aber nicht. Für den musst Du mit padding vom td und Rahmen um divs rumtricksen. Eine wirkliche Lösung ist das allerdings nicht.

<html>
<head>
<title></title>
<style type="text/css">
<!--
table.css2  {border:1px solid black; border-spacing:10px;}
table.css2 td  {border:1px solid black;}
table.ie5  {border:1px solid black;}
table.ie5 td  {padding:5px;}
table.ie5 td div {border:1px solid black;}
-->
</style>
</head>
<body>
<table class="css2">
<tr>
 <td>Zelle 1</td>
 <td>Zelle 2</td>
</tr>
<tr>
 <td>Zelle 3</td>
 <td>Zelle 4</td>
</tr>
</table>

<table class="ie5">
<tr>
 <td><div>Zelle 1</div></td>
 <td><div>Zelle 2</div></td>
</tr>
<tr>
 <td><div>Zelle 3</div></td>
 <td><div>Zelle 4</div></td>
</tr>
</table>
</body>
</html>

viele Grüße

Axel