Autor | Zpráva | ||
---|---|---|---|
Levoš Profil |
Jeden velký obrázek na stránku, na středu atd...
Prosím o radu jak definovat main, aby všechny parametry " fixed no-repeat center top" fungovaly. Takhle to není ono, opakují se a nevím co s tím. Děkuji za radu. <style type="text/css"> .#main { width: 100%; height: 100%; background: #262626 fixed no-repeat center top; padding: 0px; margin: 0px;} .one { background: url("http://sustainabuildingbelize.com/images/bgimages/1.jpg");} .two { background: url("http://sustainabuildingbelize.com/images/bgimages/2.jpg");} .three { background: url("http://sustainabuildingbelize.com/images/bgimages/4.jpg") } .four {background: url('http://sustainabuildingbelize.com/images/bgimages/5.jpg');} </style> <body id="main"> <script type="text/javascript"> var num = (Math.floor(Math.random()*4)); var array = ['one', 'two', 'three', 'four']; var elem = document.getElementById('main'); elem.classList.add(array[num]); </script> </body> |
||
Joker Profil |
#2 · Zasláno: 6. 10. 2014, 17:32:58
Levoš:
Main nechte jak je, ale v .one, .two, .three a .four nepřepisujte celé pozadí, ale jen vlastnost background-image. |
||
Chamurappi Profil |
Reaguji na Levoše:
Kde ses dozvěděl o classList u? Má špatnou podporu napříč prohlížeči, použij:
elem.className += " " + array[num]; Selektor .#main nezaměří nic, viz Třídy a identifikátory na JPW.
|
||
Levoš Profil |
#4 · Zasláno: 6. 10. 2014, 18:01:29
Díky, tak jsem to předělal a asi to funguje. Zkoušel jsem ve 4 prohlížečích. Prosím o upozornění, zda je někde chyba.
<style type="text/css"> .#rotace { padding: 0px; margin: 0px; } .one { background: url("http://sustainabuildingbelize.com/images/bgimages/1.jpg") #262626 fixed no-repeat center top; } .two { background: url("http://sustainabuildingbelize.com/images/bgimages/2.jpg") #262626 fixed no-repeat center top; } .three { background: url("http://sustainabuildingbelize.com/images/bgimages/4.jpg") #262626 fixed no-repeat center top; } .four { background: url('http://sustainabuildingbelize.com/images/bgimages/5.jpg') #262626 fixed no-repeat center top; } </style> </head> <body id="rotace"> <script type="text/javascript"> var num = (Math.floor(Math.random()*4)); var array = ['one', 'two', 'three', 'four']; var elem = document.getElementById('rotace'); elem.className += " " + array[num]; </script> </body> |
||
Trejpa Profil |
#5 · Zasláno: 6. 10. 2014, 18:03:29
Levoš:
„Prosím o upozornění, zda je někde chyba.“ Tady rozhodně: .#rotace
|
||
Levoš Profil |
#6 · Zasláno: 6. 10. 2014, 18:05:21
Trejpa:
Děkuji, omylem se vloudila :) |
||
Časová prodleva: 10 let
|
0