Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyśrodkowanie diva
Siner
post
Post #1





Grupa: Zarejestrowani
Postów: 159
Pomógł: 6
Dołączył: 2.01.2004

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


Mam problem z wyśrodkowaniem diva, pisze taki kod:
  1. <div style="margin-left: auto; margin-right: auto;">

Ale pod IE niestety to nie dziła. Jest jakiś inny sposób na wyśrodkowanie diva ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
Kill3R
post
Post #2





Grupa: Zarejestrowani
Postów: 109
Pomógł: 0
Dołączył: 10.06.2003
Skąd: Tarnobrzeg/Poznań

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


witam

bylo o tym wiele razy na forum

przyklad

  1. <style type="text/css">
  2. html, body {
  3. margin: 0;
  4. padding: 0;
  5. text-align: center /* srodkowanie dla ie */
  6. }
  7. div#allBox {
  8. margin: 0 auto; /* to dla innych przegladarek - skrocony zapis zero to gora i dol auto lewy i prawy*/
  9. width: 750px;
  10. height: 500px;
  11. text-align: left; /* wyrownanie tectu w divie do lewej */
  12. }
  13. </head>
  14. <div id="allBox">
  15. tresc diva
  16. </div>
  17. </body>
  18. </html>
Go to the top of the page
+Quote Post
Siner
post
Post #3





Grupa: Zarejestrowani
Postów: 159
Pomógł: 6
Dołączył: 2.01.2004

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


No ale ja nie chcem mieć wszystkich teksotw znajudujacych sie w divie na środku.
A ta linijka na to wpływa.
  1. text-align: center

Chcem mieć sam div na środku. Nawet jasli mam przy <p> styl "margin-left: 280px;" to i tak jest na środku.
Go to the top of the page
+Quote Post
FiDO
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 1 717
Pomógł: 0
Dołączył: 12.06.2002
Skąd: Wolsztyn..... Studia: Zielona Góra

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


No to musisz otoczyc tylko tego diva, ktorego chcesz wycentrowac, pomocniczym divem i z nim postapic analogicznie.
Go to the top of the page
+Quote Post
Siner
post
Post #5





Grupa: Zarejestrowani
Postów: 159
Pomógł: 6
Dołączył: 2.01.2004

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


Jednak prosiłbym o przykład, bo kąbinuje i mi nie wychodzi (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Kod strony wygląda mniejwiecej tak:
  1. <div style="width: 381; border: 1px solid #859C32; margin-left: auto; margin-right: auto;" id="layer1 ">
  2. <div style="width: 381;"><img src="13_21.gif"></div>
  3. <div class="tytul"><p class="tytul">Test</p>
  4. <p class="tresc">Test </p>
  5. </div>
  6. <div class="stopka">Siner</div>
  7. </div>

I jak zrobić aby <div>(layer1) był na środku strony. Także po IE, ale teskt się nię centrował.
Go to the top of the page
+Quote Post
php programmer
post
Post #6





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 5
Dołączył: 8.11.2004
Skąd: trójmiasto

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


można też zrobić tak:

Kod
position: absolute;
left: 50%;
margin-left: -połowa_długości_Diva;
width: długość_Diva


Ten post edytował php programmer 6.09.2005, 20:40:43
Go to the top of the page
+Quote Post
Kill3R
post
Post #7





Grupa: Zarejestrowani
Postów: 109
Pomógł: 0
Dołączył: 10.06.2003
Skąd: Tarnobrzeg/Poznań

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


witam ponownie

  1. <div style="text-align: center;">
  2. <div style="width: 381; border: 1px solid #859C32; margin-left: auto; margin-right: auto; text-align: left;" id="layer1 ">
  3. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur pellentesque enim et odio. Morbi nulla augue, molestie tempor, tincidunt ut,
  4. euismod vitae, nulla. Proin et lorem vel libero ullamcorper luctus. Ut sagittis dui at nunc. Nam eget arcu nec tortor ultrices luctus. Integer eget
  5. sapien. Aliquam hendrerit tellus ac diam. Etiam a quam vel metus scelerisque malesuada. Quisque felis ipsum, mattis eu, vulputate non, dapibus eget, p
  6. urus. Nunc vel dolor at nunc nonummy tristique. Morbi sodales urna vitae arcu. Integer pellentesque pellentesque dolor. Pellentesque habitant morbi
  7. tristique senectus et netus et malesuada fames ac turpis egestas. Aenean eget neque et risus congue fermentum.</p>
  8.  
  9.  
  10. </div>
  11. </div>


juz widzisz o co chodzi??
pierwszy div ma text-align: center dla Internet explorera

a w drugim jest margin-left i right auto dla np firefoxa ale w drugim tez jest text-align: leftdla zawartosci tego drugiego diva

---------------
@revyag
w moim pierwszym przykladzie jest margin: 0 auto; :-)
w drugim przxykladzie poprawialem kod sinera wiec nie zmienialem marginów :-)

Ten post edytował Kill3R 7.09.2005, 11:52:59
Go to the top of the page
+Quote Post
Siner
post
Post #8





Grupa: Zarejestrowani
Postów: 159
Pomógł: 6
Dołączył: 2.01.2004

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


Dzięki poskutkowało. Najśmiesznijsze, ze juz wcześniej tak kąbinowałem, tylko źle to wcisnąłem w kodzie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
revyag
post
Post #9





Grupa: Przyjaciele php.pl
Postów: 2 258
Pomógł: 16
Dołączył: 21.09.2004
Skąd: Kielce

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


Taka mała uwaga (IMG:http://forum.php.pl/style_emoticons/default/snitch.gif)
Wystarczy marign: 0 auto.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 23.08.2025 - 04:35