Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [CSS]wysrodkowanie diva z elementami float
elmozaur
post
Post #1





Grupa: Zarejestrowani
Postów: 518
Pomógł: 18
Dołączył: 21.07.2008

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


Witam.
Problem jest taki:

  1. <div style="margin:0 auto">
  2.  
  3. <a href="" style=""><span style="float:left">1</span></a>
  4. <a href="" style=""><span style="float:left">2</span></a>
  5. <a href="" style=""><span style="float:left">3</span></a>
  6. <a href="" style=""><span style="float:left">4</span></a>
  7. <a href="" style=""><span style="float:left">5</span></a>
  8.  
  9. </div>


Mam diva ze zmienna iloscia linkow(1-25).
chcialbym aby div byl zawsze na srodku strony niezaleznie od tego ile jest tych linkow w srodku. dodatkowo chcialbym aby linki byly pokazywane w boxie 20x20px;

Gdybym wiedzial, ile bedzie tych linkow to wystarczylo by dla diva dac width = np 100px margin:0 auto i po klopocie. niestety to pobierane jest randomem z bazy i nie wiem ile bedzie wynikow...

czy ktos ma pomysl jak to ugryzc ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
peter13135
post
Post #2





Grupa: Zarejestrowani
Postów: 1 447
Pomógł: 191
Dołączył: 26.03.2008

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


Przecież po pobraniu wyników możesz sprawdzić ile ich jest i na podstawie tej liczby obliczyć szerokość
Go to the top of the page
+Quote Post
Janusz1200
post
Post #3





Grupa: Zarejestrowani
Postów: 110
Pomógł: 6
Dołączył: 19.12.2010
Skąd: Krzyżanowice

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


Wkradł się błąd, ale poprawiłem:

<!DOCTYPE html>
<html>
<head>

<style>
a {
display: table-cell;
width: 20px;
height: 20px;
border: 1px red solid;
}
div {
display: table;
padding: 10px;
text-align: center;
margin-left: auto;
margin-right: auto;
border: 1px green solid;

}
</style>


<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>
<a href="" >1</a>
<a href="" >2</a>
<a href="" >3</a>
<a href="" >4</a>
<a href="" >5</a>

</div>
</body>
</html>

Ten post edytował Janusz1200 27.07.2011, 15:07:02
Go to the top of the page
+Quote Post
Damonsson
post
Post #4





Grupa: Zarejestrowani
Postów: 2 355
Pomógł: 533
Dołączył: 15.01.2010
Skąd: Bydgoszcz

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


Haha @Janusz1200 nie łatwiej

<body>
<table>
<tr>
<td><a>aa</a></td>
<td><a>bb</a></td>
</tr>
</table>
</body>

(czy jak to się tam robi na tabelach)

?

Po co marnować czas na pisanie display: table i display: table-cell? (IMG:style_emoticons/default/ohmy.gif)

(IMG:style_emoticons/default/withstupidsmiley.gif)

Ten post edytował Damonsson 27.07.2011, 18:07:06
Go to the top of the page
+Quote Post
Janusz1200
post
Post #5





Grupa: Zarejestrowani
Postów: 110
Pomógł: 6
Dołączył: 19.12.2010
Skąd: Krzyżanowice

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


@Elmozaur, no i jak, zastosowałeś to rozwiązanie?
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: 2.10.2025 - 22:33