Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z divami
Forum PHP.pl > Forum > Po stronie przeglądarki > CSS
Balas
Mam problem. Chce umiescic 2 divy obok siebie, Mam taki kod:

  1. <style type="text/css">
  2. body {margin: 0px; background-image: url("./images/bg.gif"); margin:0; padding:0; height:100%; text-align:center; color: #fff;}
  3. img {border: 0px; margin: 0px; padding: 0px;}
  4.  
  5. #glowny {margin: 0 auto; width: 804px; text-align: justify; background-image: url("./images/body-bg.jpg");}
  6. #text-bar {width: 100%; height: 18px; background-image: url("./images/top-text-bar.jpg"); font-size: 12px; text-align: left; vertical-align: center;}
  7. #text-bar h1 {font-size: 12px; margin:0px 10px 0px 10px; font-weight: bold; font-family: Verdana; color: #000;}
  8. #logo{width: 100%; height: 150px; background-image: url("./images/logo.jpg"); font-size: 0px;}
  9. #top-menu{width: 100%; height: 52px;}
  10. #top-menu-items{width: 100%; height: 40px; padding: 0px; margin: 0px;}
  11.  
  12. #body {width: 804px; padding: 0px; margin: 0px;}
  13. #menu {width: 162px; left: 0px;}
  14. #other {width: 642px; right: 0px;}
  15.  
  16. #footer-text {width: 100%; height:40px; background-image: url("./images/footer.jpg");}
  17.  
  18. .header-bar{width: 100%; height:12px; background-image: url("./images/header-bar.jpg"); font-size: 0px;}
  19. .bar {width: 100%; height:12px; background-image: url("./images/bar.jpg"); font-size: 0px;}
  20.  
  21. </head>
  22. <div id="glowny">
  23.  
  24. <div id="header">
  25. <div class="bar"></div>
  26. <div id="text-bar"><h1>Metal Dream - portal o Metallice i Dream Theater</h1></div>
  27. <div class="header-bar"></div>
  28. <div id="logo"></div>
  29. <div class="header-bar"></div>
  30. </div>
  31. <div id="top-menu">
  32. <div id="top-menu-items"><a href=""><img src="./images/menu-item1.jpg" alt="Strona główna"></a><a href=""><img src="./images/menu-item2.jpg" alt="Forum"></a><a href=""><img src="./images/menu-item3.jpg" alt="Download"></a><a href=""><img src="./images/menu-item4.jpg" alt="Metallica"></a><a href=""><img src="./images/menu-item5.jpg" alt="Dream Theater"></a></div>
  33. <div class="bar"></div>
  34. </div>
  35.  
  36. <div id="body">
  37. <div id="menu">cos :)<br />cos :)</div>
  38. <div id="other">cos :)<br />cos :)</div>
  39. </div>
  40.  
  41. <div id="footer">
  42. <div class="bar"></div>
  43. <div id="footer-text"></div>
  44. </div>
  45.  
  46. </div>
  47. </body>
  48. </html>


Chce zeby Menu i Other byly obok siebie i zeby rozciagaly one warstwe body. Jak to zrobic questionmark.gif probowalem z float ale wtedy sie nie rozciaga sad.gif
shpyo
HINT: float: left/right;
Balas
Pisalem ze tak robilem... ale div pod nimi ma sie tez rozciagnac na ich dlugosc sad.gif A jak tak zrobie to nie idzie smile.gif
strange
Proszę:
  1. <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
  2. <style type="text/css">img {border: 0px; margin: 0px; padding: 0px;}
  3.  
  4. #glowny {margin: 0 auto; width: 804px; text-align: justify; background-image: url("./images/body-bg.jpg");}
  5. #text-bar {width: 100%; height: 18px; background-image: url("./images/top-text-bar.jpg"); font-size: 12px; text-align: left; vertical-align: center;}
  6. #text-bar h1 {font-size: 12px; margin:0px 10px 0px 10px; font-weight: bold; font-family: Verdana; color: #000;}
  7. #logo{width: 100%; height: 150px; background-image: url("./images/logo.jpg"); font-size: 0px;}
  8. #top-menu{width: 100%; height: 52px;}
  9. #top-menu-items{width: 100%; height: 40px; padding: 0px; margin: 0px;}
  10.  
  11. #content {width: 804px; padding: 0px; margin: 0px;}
  12. #menu {width: 162px; left: 0px; float: left;}
  13. #other {width: 642px; right: 0px; float: right;}
  14.  
  15. #footer-text {width: 100%; height:40px; background-image: url("./images/footer.jpg");}
  16.  
  17. .header-bar{width: 100%; height:12px; background-image: url("./images/header-bar.jpg"); font-size: 0px;}
  18. .bar {width: 100%; height:12px; background-image: url("./images/bar.jpg"); font-size: 0px;}
  19.  
  20. </head>
  21. <div id="glowny">
  22.  
  23. <div id="header">
  24. <div class="bar"></div>
  25. <div id="text-bar"><h1>Metal Dream - portal o Metallice i Dream Theater</h1></div>
  26. <div class="header-bar"></div>
  27. <div id="logo"></div>
  28. <div class="header-bar"></div>
  29. </div>
  30. <div id="top-menu">
  31. <div id="top-menu-items"><a href=""><img src="./images/menu-item1.jpg" alt="Strona główna"></a><a href=""><img src="./images/menu-item2.jpg" alt="Forum"></a><a href=""><img src="./images/menu-item3.jpg" alt="Download"></a><a href=""><img src="./images/menu-item4.jpg" alt="Metallica"></a><a href=""><img src="./images/menu-item5.jpg" alt="Dream Theater"></a></div>
  32. <div class="bar"></div>
  33. </div>
  34.  
  35. <div id="content">
  36. <div id="menu">cos :)<br />cos :)</div>
  37. <div id="other">A tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA tu jest trescA</div>
  38. </div>
  39.  
  40. <div id="footer">
  41. <div class="bar"></div>
  42. <div id="footer-text"></div>
  43. </div>
  44.  
  45. </div>
  46. </body>
  47. </html>



Co poprawiłem, użyłeś body jako miejsca na menu i other a to jest błąd, ponieważ standardowo klasa body jest używana do określenia wyglądu pierwszej warstwy tnz. (tło, suwaki itd.)
Poprawiłem Ci nazwę na content.
A dodatkowo oczywiście floaty...


Pozdrawiam i mam nadzieję, że o to chodziło...


Poprawiłem


----edit----
Do wstawiania kodów źródłowych HTML służy tag [ html ]
Tym razem poprawiłem, ale proszę używać odpowiednich tagów bbCode
~mike_mech
Balas
Mowilem ze float juz uzywalem a po zmianie nazwy ten sam efekt sad.gif (content sie nie rozciaga. Nie wiem czemu ale pod IE wyglada jak powinno a pod FF juz nie.

Czekam na dalsze propozycje smile.gif bo sam juz mecze sie z tym i nic nie wychodzi.

PS. u ciebie jest blad bo nie to body zmieniles w stylach winksmiley.jpg

edit

  1. <style type="text/css">
  2. body {margin: 0px; background-image: url("./images/bg.gif"); margin:0; padding:0; height:100%; text-align:center; color: #fff;}
  3. img {border: 0px; margin: 0px; padding: 0px;}
  4.  
  5. #glowny {margin: 0 auto; width: 804px; text-align: justify;}
  6. #text-bar {width: 100%; height: 18px; background-image: url("./images/top-text-bar.jpg"); font-size: 12px; text-align: left; vertical-align: center;}
  7. #text-bar h1 {font-size: 12px; margin:0px 10px 0px 10px; font-weight: bold; font-family: Verdana; color: #000;}
  8. #logo{width: 100%; height: 150px; background-image: url("./images/logo.jpg"); font-size: 0px;}
  9. #top-menu{width: 100%; height: 52px;}
  10. #top-menu-items{width: 100%; height: 40px; padding: 0px; margin: 0px;}
  11.  
  12. #content {width: 804px; padding: 0px; margin: 0px;}
  13. #menu {width: 162px; left: 0px; float: left;}
  14. #other {width: 642px; right: 0px; float: right;}
  15.  
  16. #footer-text {width: 100%; height:40px; background-image: url("./images/footer.jpg"); float: right;}
  17.  
  18. .header-bar{width: 100%; height:12px; background-image: url("./images/header-bar.jpg"); font-size: 0px;}
  19. .bar {width: 100%; height:12px; background-image: url("./images/bar.jpg"); font-size: 0px;}
  20.  
  21. </head>
  22. <div id="glowny">
  23.  
  24. <div id="header">
  25. <div class="bar"></div>
  26. <div id="text-bar"><h1>Metal Dream - portal o Metallice i Dream Theater</h1></div>
  27. <div class="header-bar"></div>
  28. <div id="logo"></div>
  29. <div class="header-bar"></div>
  30. </div>
  31. <div id="top-menu">
  32. <div id="top-menu-items"><a href=""><img src="./images/menu-item1.jpg" alt="Strona główna"></a><a href=""><img src="./images/menu-item2.jpg" alt="Forum"></a><a href=""><img src="./images/menu-item3.jpg" alt="Download"></a><a href=""><img src="./images/menu-item4.jpg" alt="Metallica"></a><a href=""><img src="./images/menu-item5.jpg" alt="Dream Theater"></a></div>
  33. <div class="bar"></div>
  34. </div>
  35. <div style="float: right; background-image: url('./images/body-bg.jpg');">
  36. <div id="menu">cosdsadsad</div>
  37. <div id="other">A tu jest tresc</div>
  38. </div>
  39.  
  40.  
  41. <div class="bar" style="float: right;"></div>
  42. <div id="footer-text"></div>
  43.  
  44.  
  45. </div>
  46. </body>
  47. </html>


Zmienilem tylko w stopce i w "kontenerze" tez na float i wszystko dziala smile.gif guitar.gif

PS. czemu nie ma tego posta co przez chwila strange napisal questionmark.gif biggrin.gif laugh.gif
Zajec
Przyznaję - czytałem temat bardzo ogólnikowo.

Zakładam, że w jednym div'ie masz dwa divy z nadanym float. To, że div-rodzic się nie rozciąga jest natulanym zachowaniem. Tak funkcjonuje float, że nie wpływa na rozmiary rodzica.

Nadaj div'owi-rodzicowi jakiś id i użyj
Kod
#id:after {
display: block;
clear: both;
content: "";
}
Cała reszta pod spodem będzie już normalnie się układać. A szkoda tak z div'ami kombinować.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.