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
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 classListu? 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
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
Levoš:
Prosím o upozornění, zda je někde chyba.
Tady rozhodně: .#rotace
Levoš
Profil
Trejpa:
Děkuji, omylem se vloudila :)

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0