Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [CSS]wysrodkowanie diva z elementami float
elmozaur
post 27.07.2011, 13:34:11
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
peter13135
post 27.07.2011, 13:57:42
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 27.07.2011, 14:24:27
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 27.07.2011, 18:04:58
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? ohmy.gif

withstupidsmiley.gif

Ten post edytował Damonsson 27.07.2011, 18:07:06
Go to the top of the page
+Quote Post
Janusz1200
post 28.07.2011, 12:13:49
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
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 4.07.2025 - 21:32