Autor | Zpráva | ||
---|---|---|---|
Kry5 Profil |
#1 · Zasláno: 15. 5. 2011, 18:57:44 · Upravil/a: Kry5
Zdravím,
snažím se upravit jeden element na stránce (s id obsah) a nastavit mu css výšku podle výšky uživatelovy obrazovky. Zkusil jsem něco takového: var height = screen.availHeight; height = height - 50; height = height+"px"; document.getElementById('obsah').height = height; Bohužel to nefunguje. Nevíte, kde by mohla být chyba? Díky moc Kry5 Edit: tohle by mělo hodit výšku o 50px menší než je dostupná plocha |
||
Ernie Profil |
#2 · Zasláno: 15. 5. 2011, 19:11:57 · Upravil/a: Ernie
Kry5:
Kromě obrázků (kde je i atributem) je height vlastnost objektu style, takže: document.getElementById('obsah').style.height = height; A ještě bych to trochu zkrátil: <script> document.getElementById('obsah').style.height = (screen.availHeight-50)+"px"; </script> |
||
Ernie Profil |
#3 · Zasláno: 15. 5. 2011, 19:29:13 · Upravil/a: Ernie
Ještě k té výšce - jestli chcete maximální výšku stránky, aby byla vidět, tak jsem někde našel tuto funkci:
<script> function winH() { if (window.innerHeight) /* NN4 a kompatibilní prohlížeče */ return window.innerHeight; else if (document.documentElement && document.documentElement.clientHeight) /* MSIE6 v std. režimu - Opera a Mozilla již uspěly s window.innerHeight */ return document.documentElement.clientHeight; else if (document.body && document.body.clientHeight) /* starší MSIE + MSIE6 v quirk režimu */ return document.body.clientHeight; else return null; } </script> |
||
Kry5 Profil |
#4 · Zasláno: 15. 5. 2011, 19:44:42
Díky moc :-)
|
||
Časová prodleva: 13 let
|
0