Bardzo prosze o pomoc bo skonczyly mi sie pomysly
centrowanie tabeli
centrowanie tabeli
mam taki maly problem - zrobilem strone oparta na tabelach zgodna w calosci ze standardem xhtml 1.1 i jedynym moim problemem jaki teraz mam to wysrodkowanie glownej tabeli czyli praktycznie calej strony. Nie moge uzyc polecenia <center></center> ani tez align="center" gdyz wedlug tego standardu te komenty sa niezgodne. Probowalem zrobic to stylami ale nie moge znalezc stylu ktory by wycentrowal tabele. Owszem jest zdaje sie taxt-align, ale on centruje caly tekst jaki jest w srodku tej tabeli. Kombnowalem tez ze stylami mowiacymi o marginesach i dalem w % wartosci ale jak zmienilem rozdzielczosc na inna to sie okazalo ze te % to sie zachowuja jak stale wartosci i kicha jest strona jest przesunieta do lewej strony.
Bardzo prosze o pomoc bo skonczyly mi sie pomysly
Bardzo prosze o pomoc bo skonczyly mi sie pomysly
Re: centrowanie tabeli
Małe sprostowanie.
Tabele są jak najbardziej zgodne z XHTML'em zarówno 1.0 jak i 1.1
Niemniej jednak lepiej jest stworzyć układ oparty na div'ach.
Tabele są jak najbardziej zgodne z XHTML'em zarówno 1.0 jak i 1.1
Niemniej jednak lepiej jest stworzyć układ oparty na div'ach.
Re: centrowanie tabeli
moja wina.. nie doczytalem..
re
a ja sie bym tu klucil bo zawierzam organizacji W3C ktora odpowiada za XHTML i sprawdzilem stronke ich oficjalnym validatorkiem otrzymujac oficjalny znaczek zgodnosci i przetrzepalem wszystkie instrukcje i jakos o tabeli to pierwszy raz slysze, moze mi cos umknelo, ale tu chodzi chyba o ramki, bo ramek to wlasnie nie ma w tym standardzie
a propozycja rozwiazania ciekawa ale strona malo co opiera sie na div'ach wiec moze ktos cos powie odnosnie tabel
a propozycja rozwiazania ciekawa ale strona malo co opiera sie na div'ach wiec moze ktos cos powie odnosnie tabel
Re: centrowanie tabeli
Najprawdopodobniej i tak będziesz musiał tabelę w div'a ująć.
Wtedy dla div'a ustawiasz w arkuszu styli
Wówczas tabela się wyśrodkuje.
Wtedy dla div'a ustawiasz w arkuszu styli
Kod: Zaznacz cały
text-align: center;re
no ja powiem tak dziwy mi sie tutaj dzieja bo otoczylem calo glowna tabele czyli praktycznie cala stronke <div></div> od momentu po <body>do</body> i wpisalem styl text-align: center; ale to jest jakis maly problem bo owszem dziala ale nie na strone tylko na text i tak jak w moich innych kombinacjach tabela zostaje z lewej a text w srodki sie centruje czyli calkiem na odwrot
zrobilem jeszcze cos w stylu jak w innym poscie do ktorego podany zostal link ale w tym przypadku to tez nic sie nie stalo nie liczac tego ze w srodku tabeli to co bylo juz wysrodkowane wysrodkowalo sie jeszcze ladniej 
re
a i jeszcze jedno jako ciekawostke wpisalem do tego okalajacego div'a align="center" i oczywiscie dziala tak jak dziala gdy ten sam atrybut dam w tagu <table> tylko jak sprawdzilem validatorem to oczywiscie niezgodnosc jest i wywalo cos takiego:
"#
Line 14, column 30: there is no attribute "align"
<body class="body"><div align="center">
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.
"
"#
Line 14, column 30: there is no attribute "align"
<body class="body"><div align="center">
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.
"
Re: centrowanie tabeli
Moje niedopatrzenie. Nie podałem Ci wszystkiego 
Oprócz tego, że musisz ustawić text-align: center dla div'a, to jeszcze dla tabeli musisz dać style="margin-left: auto; margin-right: auto;".
Po tym manewrze nie ma możliwości żeby nie działało.
Oprócz tego, że musisz ustawić text-align: center dla div'a, to jeszcze dla tabeli musisz dać style="margin-left: auto; margin-right: auto;".
Po tym manewrze nie ma możliwości żeby nie działało.
re
Tak jak kolega podal wszystko jest ok dla div'a wartosc text-align: center; i dla tebel marginesy. No to siup i jest tabela na srodku ale jej zawartosc tez jest wysrodkowana a miala byc do lewej. No to rozwiazanie jest takie ze trzeba wywalic tego nadrzednego div'a z wartoscia centrujaca i jest ok tabela na srodku i wartosc do lewej.
Po takich zmianach w IE problem jest nadal i jeszcze nie wiem czemu nie dzialaja style w niektorych tabelkach wewnetrznych, ale to moze byc pikus bo trzeba bedzie pewnie nadas styl kazdej komorce osobno wiec sie zrobi. No ale z centrowaniem to rozwiazanie jest dokladnie takie jak podal kolega trzeba tego div'a dodac i wtedy dziala bo strona jest na srodku i w przeciwienstwie do firefox'a text jest nie wysrodkowany ale do lewej wiec zachodzi to sprzecznosc.
Najpierw trzeba zrobic tak jak to bylo juz powiedziane dla div'a wartosc center a dla glownej tabeli marginesy. I mamy IE z glowy, a jesli komus nie dzialaja w wewnetrznych tabelach style (plik zewnetrzny css) zdefiniowane przy poleceniu body przez class="xxx" to trzeba do kazdej wewnetrznej tabeli czy tez komorki dodac dodatkowo odpowiedni styl. Jak juz bedziemy sie tu bawic ze stylami to warto dodac do tego glownego stulu (class="xxx") wartosc text-align: left; lub jak kto woli stworzyc oddzielny styl od wyrownywania np. class="ccc" i w tym momencie mamy IE oraz Firefoxa z glowy a wszystko jest ladnie poukladane
Ostatnio zmieniony śr lut 02, 2005 4:50 pm przez nietophez, łącznie zmieniany 2 razy.
Re: centrowanie tabeli
Kod: Zaznacz cały
td {
text-align: left;
}re
Dzieki za odpowiedz ale to samo napisalem doslownie linijke wyzej
W tym momencie dziekuje wszystkim za zainteresowanie i odpowiedzi oraz goraco pozdrawiam.
W tym momencie dziekuje wszystkim za zainteresowanie i odpowiedzi oraz goraco pozdrawiam.

