Thomas J.S.: CSS mit Javascript - dringend!

Beitrag lesen

Hallo!

So ähnlich will das ja auch machen. Nur wie positioniere ich dann z.B. folgendes (einfache) Untermenü:

<div id="sub" style="position:absolute; top:40; left:80">
  <table cellpadding=0 cellspacing=0 border=1>
  <tr><td class="mstyle" height=20 width=80>Select31</td></tr>
  <tr><td class="mstyle" height=20 width=80>Select32</td></tr>
  <tr><td class="mstyle" height=20 width=80>Select33</td></tr>
  </table>
</div>

Die Position top:40 und left:80 sollen durch Variablen gesetzt werden!

Ich bin kein können beim JavaScript:
Du muss mit document.write eine CSS für dieses Menü schreiben:
nur als Idee! Javascript im Header.

var x,y
  x = 80;
  y = 40;

subX = x+20;
         subY = y+20;
         subsubX = sub+20;
         subsubY = sub+20;

document.write("<style type="text/css">");
         document.write("#sub { postion:absolute; top:"+y+"; left:"+x+"; }");
         document.write("#sub1 { postion:absolute; top:"+subY+"; left:"+subX+"; }");
         document.write("</style>");

Irgendwo in der Seite dann:
<div id="sub">
...
<div id="sub1">

Und so weiter: aber wie gesagt ist nur eine Idee und keine echte Lösung.

Grüße
Thomas