Autor Beitrag
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Fr 18.09.09 00:06 
Hallo ihr,

ich möchte ein div auf 100% Höhe des Browsers bringen. Bekanntlichermaßen ist das bei Browsern momentan noch nicht problemlos möglich. Aus diesem Grund mache ich das per JS. Dabei stehe ich jetzt vor folgendem Problem:

im Body befindet sich ein Div das rot eingefärbt ist. Man sieht jetzt das die Browser rundherum einen weißen Abstand lassen, den man per body einfärben kann. FireBug zeigt mir an das der Body margin-Werte von 8px hat, Jedoch ist das feld body.style.marginTop etc. leer. Woher bekomme ich die 8px? Denn man kann die ja per CSS beeinflussen, von daher kann ich die 8 nicht hardcoden (was eh unsauber wäre).

besten Dank im Voraus
Heiko
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 18.09.09 10:37 
Wieso musst du die denn auslesen?
Wenn du die HTML Seite eh selber machst, dann setzte doch einfach per CSS diesen Wert auf 0.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 18.09.09 10:59 
Hi

ich definieren im CSS erstmal alle borders, margins und paddings so:
ausblenden XML-Daten
1:
2:
3:
4:
  <style><!--
    * {border: 0px; margin: 0px; padding: 0px;}
    #myDiv {height: 100%} /*dann so das div auf die hoehe bringen*/
  -->
</style>


im html dann so

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
...
<body>
  <div id="myDiv">
  </div>
</body>
...
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 18.09.09 14:39 
Dann sollte das eigentlich gehen. So setze ich das bei einem Projekt auch um...

Meebo übrigens auch.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Fr 18.09.09 14:46 
Hallo ihr,

CSS bringt mir an der Stelle nichts, denn es handelt sich dabei um eine Art Framework. Und zwar soll es iFrames verwalten - und die iFrames sollen halt so hoch sein wie möglich, nur halt das kein Scrollbalken erscheint. Von daher will ich hier CSS weglassen damit es allgemeingültig ist (und somit müsste ich es in meiner Fomrel einfließen lassen) ;)

Heiko
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Fr 18.09.09 15:35 
So mit Martok haben wir es jetzt herausbekommen :). Nur bei User-CSS könnte es ggf. Probleme geben, falls statt px % oder so angegeben wurde ;)

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
getComputedStyle: function(obj, style)
{
  if (window.getComputedStyle) {
    return parseInt(window.getComputedStyle(obj, "")[style]);
  } else if (obj.currentStyle) {
    return parseInt(obj.currentStyle[style]);
  }
}

area.style.height = (document.documentElement.clientHeight - document.body.clientHeight - getComputedStyle(document.body, "marginTop") - getComputedStyle(document.body, "marginBottom") + area.clientHeight)+'px';


€: JS-Code IE tauglich gemacht