Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Dwa divy jeden pod drugim - problem z położeniem
MrGohut
post
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 29.04.2013

Ostrzeżenie: (0%)
-----


Mam problem z dwoma divami. Chcę dodać div pod już istniejącym divem, ma być po środku. Obecnie mam tak:
  1. <div id="newsy" clear="left">
  2. <script type="text/javascript">
  3. // <![CDATA[
  4. var news = new News();
  5.  
  6. /////
  7. // Dodawanie newsów w postaci:
  8. // news.dodaj(dzień,miesiąc,rok,
  9. // 'Tytuł','Treść newsa...',
  10. // 'adres','ramka',
  11. // 'autor','e-mail',
  12. // 'obrazek',szerokość,wysokość);
  13. /////
  14.  
  15. //////////
  16. // Dodawanie newsów:
  17. news.dodaj(29,04,2013, 'Testowy News', 'Testowy news');
  18. //////////
  19.  
  20. news.wyswietl();
  21. // ]]>
  22. </script>
  23. </div>
  24. <div id="formularz" clear="left">
  25. TEST
  26. </div>

I CSS:
  1. #newsy {
  2. float: left;
  3. color: #333;
  4. border: 1px solid #ccc;
  5. background: #F2F2E6;
  6. margin: 0px 5px 5px 0px;
  7. padding: 10px;
  8. height: 350px;
  9. width: 456px;
  10. }
  11. #formularz{
  12. float: left;
  13. color: #333;
  14. border: 1px solid #ccc;
  15. background: #F2F2E6;
  16. margin: 0px 5px 5px 0px;
  17. padding: 10px;
  18. height: 350px;
  19. width: 456px;

Ale niestety ten drugi div (formularz) nie ukłąda się na środku pod newsami tylko jakoś wypycha go na lewo ;/ Kombinowałem godzine i już nie mam pomysłów : D (Pierwszy raz z divami tongue.gif )
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 12)
ssstrz
post
Post #2





Grupa: Zarejestrowani
Postów: 103
Pomógł: 17
Dołączył: 15.12.2012

Ostrzeżenie: (0%)
-----


  1. #newsy {
  2. float: left;
  3. color: #333;
  4. border: 1px solid #ccc;
  5. background: #F2F2E6;
  6. margin: 0px 5px 5px 0px;
  7. padding: 10px;
  8. height: 350px;
  9. width: 456px;
  10. }
  11. #formularz{
  12. margin:auto;
  13. color: #333;
  14. border: 1px solid #ccc;
  15. background: #F2F2E6;
  16.  
  17.  
  18. height: 350px;
  19. width: 456px;
  20. }

wywal to clear="left" z htmla <div id="formularz" clear="left">
Go to the top of the page
+Quote Post
sunpietro
post
Post #3





Grupa: Zarejestrowani
Postów: 262
Pomógł: 26
Dołączył: 23.01.2009
Skąd: eZ Systems

Ostrzeżenie: (0%)
-----


Kłaniają się podstawy. Usuń float: left z divów.
Jak rozumiem, tym drugim div jest #formularz, w takim razie do niego daj margin: 0px auto 5px;
Z kodu HTML usuń: clear="left", to są style CSS ktore się daje do pliku CSS bezpośrednio.


--------------------
Go to the top of the page
+Quote Post
MrGohut
post
Post #4





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 29.04.2013

Ostrzeżenie: (0%)
-----


Wszystko jest ok. kod css jest w pliku .css, spokojnie smile.gif

Zmieniłem ten css na ten co mi podałeś no i po części niby jest dobrze, napis jest we właściwym miejscu, jednak tło wywaliło do góry, sami zobaczcie:
http://img547.imageshack.us/img547/8523/beztytuuiow.png
wywaliłem też clear="left" z divów

Ten post edytował MrGohut 29.04.2013, 20:01:07
Go to the top of the page
+Quote Post
joordan
post
Post #5





Grupa: Zarejestrowani
Postów: 51
Pomógł: 1
Dołączył: 15.06.2010

Ostrzeżenie: (10%)
X----


chodzi o coś takiego..questionmark.gif


  1. <STYLE type="text/css">
  2. #newsy {
  3.  
  4. color: #333;
  5. border: 1px solid #ccc;
  6. background: #F2F2E6;
  7. margin-right: auto;
  8. margin-left: auto;
  9. margin-bottom:5px;
  10. padding: 10px;
  11. height: 350px;
  12. width: 456px;
  13. }
  14. #formularz{
  15. clear:both;
  16. color: #333;
  17. border: 1px solid #ccc;
  18. background: #F2F2E6;
  19. margin-left: auto;
  20. margin-right: auto;
  21. padding: 10px;
  22. height: 350px;
  23. width: 456px;
  24. </STYLE>
  25. </head>
  26. <div id="newsy" >
  27. aaaaaa
  28. </div>
  29. <div id="formularz" >
  30. TEST
  31. </div>
  32.  
  33.  
  34. </body>
  35. </html>


Ten post edytował joordan 29.04.2013, 20:09:54
Go to the top of the page
+Quote Post
MrGohut
post
Post #6





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 29.04.2013

Ostrzeżenie: (0%)
-----


Teraz to już w ogóle wszystko się poprzestawiało na stronce ;/

Chodzi o to, żeby ten napis TEST z tym tłem kremowym (takie samo tło jak na newsach) był pod tymi newsami . Prostokąt pod prostokątem ; P

Ten post edytował MrGohut 29.04.2013, 20:22:31
Go to the top of the page
+Quote Post
joordan
post
Post #7





Grupa: Zarejestrowani
Postów: 51
Pomógł: 1
Dołączył: 15.06.2010

Ostrzeżenie: (10%)
X----


Jak mam ci pomóc jak nie dajesz kodu całej strony z kont mam wiedzieć w której klasie albo identyfikatorze jest błąd...? A jak mówisz o konkretnych divach to pisz blok "id=formularz" bo tak to bez sensu....
Go to the top of the page
+Quote Post
MrGohut
post
Post #8





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 29.04.2013

Ostrzeżenie: (0%)
-----


Proszę bardzo, macie indexa i css\'a :
Kod
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Tytul</title>
        <link rel="stylesheet" type="text/css" href="main.css" />
        <link rel="stylesheet" type="text/css" href="menu.css" />
        <link rel="Stylesheet" type="text/css" href="galeria.css" />
        <link rel="Stylesheet" type="text/css" href="news.css" />
        <script type="text/javascript" charset="iso-8859-2" src="news.js"></script>
        <script type="text/javascript" src="galeria.js"></script>
    </head>
    <body>
        <!-- Begin Wrapper -->
        <div id="wrapper">
            <!-- Begin Header -->
            <div id="header">
                <center>
                    TUTAJ JEST LOGO
                </center>
            </div>
            <!-- End Header -->
            <!-- Begin Left Column -->
            <div id="leftcolumn">
                <center>
                    <table>
                        <ul>
                            <li><a href="#">Menu1</a></li>
                            <li><a href="#">Menu2</a></li>
                            <li><a href="#">Menu3</a></li>
                            <li><a href="#">Menu4</a></li>
                        </ul>
                    </table>
                </center>
            </div>
            <!-- End Left Column -->
            <!-- Begin Content Column -->
            <div id="newsy">
                <script type="text/javascript">
                    // <![CDATA[
                        var news = new News();
                        
                        /////
                        // Dodawanie newsów w postaci:
                        // news.dodaj(dzien,miesiac,rok,
                        //   'Tytul','Tresc newsa...',
                        //   'adres','ramka',
                        //   'autor','e-mail',
                        //   'obrazek',szerokosc,wysokosc);
                        /////

                        //////////
                        // Dodawanie newsów:
                        news.dodaj(29,04,2013, 'Testowy News', 'Testowy news');
                        //////////

                        news.wyswietl();
                    // ]]>
                </script>
            </div>
            <div id="formularz">
                TEST
            </div>
            <!-- End Content Column -->
            <!-- Begin Right Column -->
            <div id="rightcolumn">
                <script type="text/javascript">
                    // <![CDATA[
                        var galeria = new Galeria('galeria', new Array(
                            new Array('midk.jpg', '', 'Tytul', ''),
                            new Array('mwola.jpg', '', 'Tytul', ''),
                            new Array('mtablica.jpg', '', 'Tytul', ''),
                            new Array('mmieszkanie.jpg', '', 'Tytul', '')
                        ), 'galeria.css', true);
                    // ]]>
                </script>
            </div>
            <!-- End Right Column -->
            <!-- Begin Footer -->
            <div id="footer">
                ? 2013 - <?php echo date("Y"); ?>   qwerty
            </div>
            <!-- End Footer -->
        </div>
        <!-- End Wrapper -->
    </body>
</html>

Kod
/*
      Created by Keith Donegan of Code-Sucks.com
      
      E-Mail: Keithdonegan@gmail.com
      
      You can do whatever you want with these layouts,
      but it would be greatly appreciated if you gave a link
      back to http://www.code-sucks.com
      
*/

* { padding: 0; margin: 0; }

body {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
#wrapper {
margin: 0 auto;
width: 1000px;
}
#header {
color: #333;
width: 940px; /*szerokość loga*/
float: left;
padding: 10px;
border: 1px solid #ccc;
height: 100px; /*wyskokość loga*/
margin: 10px 0px 5px 0px;
background: #BD9C8C;
}
#leftcolumn {
color: #333;
border: 1px solid #ccc;
background: #E7DBD5;
margin: 0px 5px 5px 0px;
padding: 10px;
height: 128px;
width: 195px;
float: left;
}
#newsy {
float: left;
color: #333;
border: 1px solid #ccc;
background: #F2F2E6;
margin: 0px 5px 5px 0px;
padding: 10px;
height: 350px;
width: 456px;
}
#formularz{
margin: auto;
color: #333;
border: 1px solid #ccc;
background: #F2F2E6;
height: 350px;
width: 456px;
}
#rightcolumn {
color: #333;
border: 1px solid #ccc;
background: #E7DBD5;
margin: 0px 0px 5px 0px;
padding: 10px;
height: 752px;
width: 235px;
float: left;
}
#footer {
width: 940px;
clear: both;
color: #333;
border: 1px solid #ccc;
background: #BD9C8C;
margin: 0px 0px 10px 0px;
padding: 10px;
}


Ten post edytował MrGohut 29.04.2013, 20:58:56
Go to the top of the page
+Quote Post
joordan
post
Post #9





Grupa: Zarejestrowani
Postów: 51
Pomógł: 1
Dołączył: 15.06.2010

Ostrzeżenie: (10%)
X----


Musisz robić kolumny w ten sposób

_______
|top|
______
|lewa|srodek|prwa|
|lewa|srodek|prwa|
|lewa|srodek|prwa|
|lewa|srodek|prwa|
_______
|fotter|
______


  1. <STYLE type="text/css">
  2. * { padding: 0; margin: 0; }
  3.  
  4. body {
  5. font-family: Arial, Helvetica, sans-serif;
  6. font-size: 13px;
  7. }
  8. #wrapper {
  9. margin: 0 auto;
  10. width: 1000px;
  11. }
  12. #header {
  13. color: #333;
  14. width: 940px; /*szerokość loga*/
  15. float: left;
  16. padding: 10px;
  17. border: 1px solid #ccc;
  18. height: 100px; /*wyskokość loga*/
  19. margin: 10px 0px 5px 0px;
  20. background: #BD9C8C;
  21. }
  22. #leftcolumn {
  23. color: #333;
  24. border: 1px solid #ccc;
  25. background: #E7DBD5;
  26. margin: 0px 5px 5px 0px;
  27. padding: 10px;
  28. height: 128px;
  29. width: 195px;
  30. float: left;
  31. }
  32. #newsy {
  33. float: left;
  34.  
  35. color: #333;
  36. border: 1px solid #ccc;
  37. background: #F2F2E6;
  38. margin: 0px 5px 5px 0px;
  39. padding: 10px;
  40. height: 350px;
  41. width: 456px;
  42. }
  43.  
  44. #columna_srodek {
  45. float: left;
  46. padding-right:16px;
  47.  
  48. min-height: 360px;
  49. width: 466px;
  50. }
  51. #formularz{
  52. float: left;
  53. color: #333;
  54. border: 1px solid #ccc;
  55. background: #F2F2E6;
  56. margin-left: auto;
  57. margin-right: auto;
  58. padding: 10px;
  59. height: 350px;
  60. width: 456px;
  61. }
  62. #rightcolumn {
  63. color: #333;
  64. border: 1px solid #ccc;
  65. background: #E7DBD5;
  66. margin: 0px 0px 5px 0px;
  67. padding: 10px;
  68. height: 752px;
  69. width: 235px;
  70. float: left;
  71. }
  72. #footer {
  73. width: 940px;
  74. clear: both;
  75. color: #333;
  76. border: 1px solid #ccc;
  77. background: #BD9C8C;
  78. margin: 0px 0px 10px 0px;
  79. padding: 10px;
  80. }
  81. </STYLE>
  82. </head>
  83. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  84. <html xmlns="http://www.w3.org/1999/xhtml">
  85. <head>
  86. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  87. <title>Tytul</title>
  88.  
  89. </head>
  90. <body>
  91. <!-- Begin Wrapper -->
  92. <div id="wrapper">
  93. <!-- Begin Header -->
  94. <div id="header">
  95. TUTAJ JEST LOGO
  96. </center>
  97. </div>
  98. <!-- End Header -->
  99. <!-- Begin Left Column -->
  100. <div id="leftcolumn">
  101. <ul>
  102. <li><a href="#">Menu1</a></li>
  103. <li><a href="#">Menu2</a></li>
  104. <li><a href="#">Menu3</a></li>
  105. <li><a href="#">Menu4</a></li>
  106. </ul>
  107. </table>
  108. </center>
  109. </div>
  110. <!-- End Left Column -->
  111. <!-- Begin Content Column -->
  112. <div id="columna_srodek">
  113. <div id="newsy">
  114. <script type="text/javascript">
  115. // <![CDATA[
  116. var news = new News();
  117.  
  118. /////
  119. // Dodawanie newsów w postaci:
  120. // news.dodaj(dzien,miesiac,rok,
  121. // 'Tytul','Tresc newsa...',
  122. // 'adres','ramka',
  123. // 'autor','e-mail',
  124. // 'obrazek',szerokosc,wysokosc);
  125. /////
  126.  
  127. //////////
  128. // Dodawanie newsów:
  129. news.dodaj(29,04,2013, 'Testowy News', 'Testowy news');
  130. //////////
  131.  
  132. news.wyswietl();
  133. // ]]>
  134. </script>
  135.  
  136. </div>
  137. <div id="formularz">
  138. TEST
  139. </div>
  140. </div>
  141. <!-- End Content Column -->
  142. <!-- Begin Right Column -->
  143. <div id="rightcolumn">
  144. <script type="text/javascript">
  145. // <![CDATA[
  146. var galeria = new Galeria('galeria', new Array(
  147. new Array('midk.jpg', '', 'Tytul', ''),
  148. new Array('mwola.jpg', '', 'Tytul', ''),
  149. new Array('mtablica.jpg', '', 'Tytul', ''),
  150. new Array('mmieszkanie.jpg', '', 'Tytul', '')
  151. ), 'galeria.css', true);
  152. // ]]>
  153. </script>
  154. </div>
  155. <!-- End Right Column -->
  156. <!-- Begin Footer -->
  157. <div id="footer">
  158. ? 2013 - <?php echo date("Y"); ?> qwerty
  159. </div>
  160. <!-- End Footer -->
  161. </div>
  162. <!-- End Wrapper -->
  163. </body>
  164. </html>
  165.  
  166.  
  167. </body>
  168. </html>


Skasuj ten <center> i zamień na coś sęnsownego. Poczytaj jakiś współczesny kurs html css
Go to the top of the page
+Quote Post
MrGohut
post
Post #10





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 29.04.2013

Ostrzeżenie: (0%)
-----


Dzięki wielkie ! smile.gif
Z tym center też dzięki za radę, zrobiłem tak:
  1. <div id="leftcolumn" align="center">

zamiast tego <center></center>
Go to the top of the page
+Quote Post
joordan
post
Post #11





Grupa: Zarejestrowani
Postów: 51
Pomógł: 1
Dołączył: 15.06.2010

Ostrzeżenie: (10%)
X----


Te <table> też usuń bo nic nie wprowadza brak <tr><tb> Pamiętaj że align stosowany jest tylko przy tekście tongue.gif
Go to the top of the page
+Quote Post
MrGohut
post
Post #12





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 29.04.2013

Ostrzeżenie: (0%)
-----


Aha, ok dzięki za radę smile.gif

Może mi ktoś jeszcze powiedzieć jak mogę wrzucić tło na stronę ale tak, żeby nie powielało się i jak przewijam stronę, to żeby tło zostało w miejscu ?
Go to the top of the page
+Quote Post
joordan
post
Post #13





Grupa: Zarejestrowani
Postów: 51
Pomógł: 1
Dołączył: 15.06.2010

Ostrzeżenie: (10%)
X----


zobacz

Więcej na ten temat
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 10:02