Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Div zamiast tabelki
Forum PHP.pl > Forum > Po stronie przeglądarki > CSS
JaRoPHP
[/HTML]Witam!!!

Chcę zrobić układ podobny do tego (ten jest oparty na tabelce):
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
  3. </head>
  4.  
  5.  
  6. <table border="0" style="width: 75px; height: 75px;" cellpadding="0" cellspacing="1">
  7. <tr>
  8. <td style="background: #666666; width: 24px; height: 24px"></td>
  9. <td style="background: #999999; width: 24px; height: 24px"></td>
  10. <td style="background: #CCCCCC; width: 24px; height: 24px"></td>
  11. </tr>
  12. <tr>
  13. <td style="background: #999999; width: 24px; height: 24px"></td>
  14. <td style="background: #CCCCCC; width: 24px; height: 24px"></td>
  15. <td style="background: #FFFFFF; width: 24px; height: 24px"></td>
  16. </tr>
  17. <tr>
  18. <td style="background: #CCCCCC; width: 24px; height: 24px"></td>
  19. <td style="background: #FFFFFF; width: 24px; height: 24px"></td>
  20. <td style="background: #666666; width: 24px; height: 24px"></td>
  21. </tr>
  22.  
  23. </body>
  24. </html>


Ale chcę to zrobić za pomocą divów (po tabel nie powinno się używać do formatowania layoutu).
Napisałem coś takiego:

  1. <div style="position: relative; top: 0px; left: 0px; width: 24px; height: 24px; background-color: #666666;"></div>
  2. <div style="position: relative; top: -24px; left: 25px; width: 24px; height: 24px; background-color: #999999;"></div>
  3. <div style="position: relative; top: -48px; left: 50px; width: 24px; height: 24px; background-color: #CCCCCC;"></div>
  4. <div style="position: relative; top: -47px; left: 0px; width: 24px; height: 24px; background-color: #999999;"></div>
  5. <div style="position: relative; top: -71px; left: 25px; width: 24px; height: 24px; background-color: #CCCCCC;"></div>
  6. <div style="position: relative; top: -70px; left: 0px; width: 24px; height: 24px; background-color: #CCCCCC;"></div>
  7. <div style="position: relative; top: -94px; left: 50px; width: 24px; height: 24px; background-color: #666666;"></div>


ale to działa tylko pod niektórymi przeglądarkami. Pod IE pojawia się dość dużo wolnej przestrzeni - jak się doda div i ramkę to jest to dość widoczne:

  1. <div style="border: 1px solid #000000;">
  2. <div style="position: relative; top: 0px; left: 0px; width: 24px; height: 24px; background-color: #666666;"></div>
  3. <div style="position: relative; top: -24px; left: 25px; width: 24px; height: 24px; background-color: #999999;"></div>
  4. <div style="position: relative; top: -48px; left: 50px; width: 24px; height: 24px; background-color: #CCCCCC;"></div>
  5. <div style="position: relative; top: -47px; left: 0px; width: 24px; height: 24px; background-color: #999999;"></div>
  6. <div style="position: relative; top: -71px; left: 25px; width: 24px; height: 24px; background-color: #CCCCCC;"></div>
  7. <div style="position: relative; top: -70px; left: 0px; width: 24px; height: 24px; background-color: #CCCCCC;"></div>
  8. <div style="position: relative; top: -94px; left: 50px; width: 24px; height: 24px; background-color: #666666;"></div></div>


(czytając specyfikację, jest to właściwe zachowanie).
Lecz gdy zamknę to w inny div, już powinno być dobrze, ale nie jest.

Mam nadzieję, że ktoś robił juz coś podobnego, i pewno znalazł lepsze rozwiązanie, od zaproponowanego powyżej.
revyag
  1. <div style="width:76px">
  2. <div style="float:left;width:24px;height:24px;background-color: #666666;margin: 0 1px 0 0"></div>
  3. <div style="float:left;width:24px;height:24px;background-color: #999999;margin: 0 1px 0 0"></div>
  4. <div style="float:left;width:24px;height:24px;background-color: #cccccc"></div>
  5. <div style="float:left;width:24px;height:24px;background-color: #999999;margin: 1px 1px 0 0"></div>
  6. <div style="float:left;width:24px;height:24px;background-color: #cccccc;margin: 1px 1px 0 0"></div>
  7. <div style="float:left;width:24px;height:24px;background-color: #ffffff;margin: 1px 0 0 0"></div>
  8. <div style="float:left;width:24px;height:24px;background-color: #cccccc;margin: 1px 1px 0 0"></div>
  9. <div style="float:left;width:24px;height:24px;background-color: #ffffff;margin: 1px 1px 0 0"></div>
  10. <div style="float:left;width:24px;height:24px;background-color: #666666;margin: 1px 0 0 0"></div>
  11. </div>
JaRoPHP
Dzieki serdeczne...
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.