Abstand zwischen td-rand und table-rand
Martin
- css
0 Axel Richter0 Martin
0 MudGuard
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.
.td{
border : 1px solid Black;
font : 11px Verdana,sans-serif;
margin-top:234px;
}
.table{
background-color : Black;
border : 1px solid Black;
margin-top:234px;
}
____________
<table class="table">
<tr>
<td class="td"><a class="menu" href="">Startseite</a></td>
<td class="td"><a class="menu" href="">Startseite</a></td>
</tr>
</table>
was mache ich falsch?
martin
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
hallo axel,
vielen dank das du dir so viel mühe gegeben hast.
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.
ich kann trotzdem nicht verstehen warum man für sowas einfaches so einen umweg machen muss. :(
wenn margin-top schon nicht geht sollte man halt border-spacing-top einführen.
martin
Hi,
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.
Füge eine leere Zeile/Spalte mit der gewünschten Höhe/Breite an der Seite der Tabelle ein, wo Du den zusätzlichen Rand haben willst.
Setze für diese Zeile/Spalte (es bietet sich colspan/rowspan an) die border auf none.
cu,
Andreas