Forum Webmastera, HTML, CSS, PHP, MySQL, Hosting, Domeny - Forum dla Webmasterów
[CSS] Problem z tłem stronki - Wersja do druku

+- Forum Webmastera, HTML, CSS, PHP, MySQL, Hosting, Domeny - Forum dla Webmasterów (https://www.webmastertalk.pl)
+-- Dział: Technologie internetowe - tworzenie stron WWW (https://www.webmastertalk.pl/forum-technologie-internetowe-tworzenie-stron-www)
+--- Dział: xHTML, CSS, JavaScript (https://www.webmastertalk.pl/forum-xhtml-css-javascript)
+--- Wątek: [CSS] Problem z tłem stronki (/thread-css-problem-z-tlem-stronki)



[CSS] Problem z tłem stronki - Asharon Drakan - 19-06-2010

Witem
Robię stronkę i mam mały problem z tłem
Chodzi mi o to, by wykonać tło strony dopasowujące się automatycznie do rozdzielczości ekranu?
Za tło robi zdjęcie i jeśli ustawię zdjęcie o rozdzielczości 800x600 a wyświetlam stronkę np w 1280x1024 to zdjęcie albo się powiela, albo po dopisaniu linijki w kodzie jest statyczne a reszta tła pozostaje biała, natomiast jeśli ustawię tło na 1280x1024 a odpalam stronkę z 800x600 to zdjęcie jest ucięte
Jest jakiś kod który automatycznie dopasuje zdjęcie tła do rozdzielczości?
Z góry dzięki za info Smile


RE: [CSS] Problem z tłem stronki - Dhofca - 19-06-2010

Kod:
img.bg {
min-height: 100%;
min-width: 1024px;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
}

Masz szczęście, bo akurat coś takiego robiłem. Proszę. Wink


RE: [CSS] Problem z tłem stronki - Asharon Drakan - 19-06-2010

Kod:
/*STRONA*/
body {
    background-image: url(tlo2.jpg);
    background-attachment: fixed;
    margin: 0;
    padding: 0;
}
img.bg {
min-height: 100%;
min-width: 1024px;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
}
/*/STRONA*/

Zrobiłem to w ten sposób, niestety dalej jest to samo ;/


RE: [CSS] Problem z tłem stronki - KeeL - 19-06-2010

(19-06-2010, 16:00)Asharon Drakan napisał(a):
Kod:
/*STRONA*/
body {
    background-image: url(tlo2.jpg);
    background-attachment: fixed;
    margin: 0;
    padding: 0;
}
img.bg {
min-height: 100%;
min-width: 1024px;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
}
/*/STRONA*/

Zrobiłem to w ten sposób, niestety dalej jest to samo ;/

A dodałeś do tego zdjęcia odpowiednią klasę?

Podaj najlepiej kod HTML


RE: [CSS] Problem z tłem stronki - Asharon Drakan - 19-06-2010

Kod:
<body>
<div id="top">
    <div id="BODY">
        <div id="LOGO"><!--LOGO--><img src="Baner.jpg" width="733" height="150" border="0" alt="Rozmiar: 11556 bajtów" title="Rozmiar: 11556 bajtów" /><!--/LOGO--></div>
        <div id="LINKI">
        </div>
        <div id="MENU">
            <!--MENU-->
            <div class="MENU">
                <div class="NAGLOWEK" id="MENU_NAGLOWEK"><!--NAGLOWEK MENU--><!--/NAGLOWEK MENU--></div>
                <div class="ZAWARTOSC">
                <!--ZAWARTOSC MENU-->
                    <ul>
                    <li><a href="o mnie.html"><img src="O mnie.png" width="190" height="80" border="0" alt="" title="" onmouseover="if(document.images) this.src='O mnie2.png'" onmouseout="if(document.images) this.src='O mnie.png'" /></a></li>

Tak wygląda to w html, do niego jest podpięty styl w css


RE: [CSS] Problem z tłem stronki - KeeL - 19-06-2010

(19-06-2010, 19:08)Asharon Drakan napisał(a):
Kod:
<body>
<div id="top">
    <div id="BODY">
        <div id="LOGO"><!--LOGO--><img src="Baner.jpg" width="733" height="150" border="0" alt="Rozmiar: 11556 bajtów" title="Rozmiar: 11556 bajtów" /><!--/LOGO--></div>
        <div id="LINKI">
        </div>
        <div id="MENU">
            <!--MENU-->
            <div class="MENU">
                <div class="NAGLOWEK" id="MENU_NAGLOWEK"><!--NAGLOWEK MENU--><!--/NAGLOWEK MENU--></div>
                <div class="ZAWARTOSC">
                <!--ZAWARTOSC MENU-->
                    <ul>
                    <li><a href="o mnie.html"><img src="O mnie.png" width="190" height="80" border="0" alt="" title="" onmouseover="if(document.images) this.src='O mnie2.png'" onmouseout="if(document.images) this.src='O mnie.png'" /></a></li>

Tak wygląda to w html, do niego jest podpięty styl w css

Wydaję mi się że do tej linijki:
Kod:
<img src="Baner.jpg" width="733" height="150" border="0" alt="Rozmiar: 11556 bajtów" title="Rozmiar: 11556 bajtów" />

Powinieneś dopisać gdzieś klasę, albo id, a w kodzie css odpowiednio się do tego odwołać.

A zastanawia mnie co to jest ten Rozmiar: 11556bajtów ?


RE: [CSS] Problem z tłem stronki - Dhofca - 20-06-2010

Tak, oczywiście jeżeli chcesz zrobić taki trick nie możesz usatwiać tła poprzez css: body {backgound: ... }.
Musisz wstawić zdjęcie normalnie w kodzie strony:
<img src="sciezka" class="bg" alt="" />