25-12-2010, 22:32
<div class="container">
<h1 class="header"></h1>
<ul class="menu"></ul>
<div class="content"></div>
<div class="footer"></div>
</div>
.container {width:960px; margin:0 auto;}
.header {width:960px; height:150px; oveflow:hidden; text-indent:-999px;}
.menu {width:960px; height:30px;}
.menu li {float:left; width....; height:30px;}
.menu li a {display:block; width:100%; height:30px; overflow:hidden; text-indent:-999px;}
.content {width:960px;}
.footer {width:960px; clear:both; height:100px;}
Tak naprawdę width nie będzie potrzebny, bo te elementy są typu block czyli mają width 100%.
Ogólnie najlepiej stosować właśnie taką konstrukcję. To taka baaardzo ogólna struktura.
Jezeli jednak masz umieszczony h1 jako oddzielny element, wtedy centrujesz go
margin:0 auto
Piewsza wartość to y, druga to x. Jeżeli ustawiona jest na auto - wtedy centruje dany element. Ale tylko wtedy gdy ma on ustawioną szerokość.
<h1 class="header"></h1>
<ul class="menu"></ul>
<div class="content"></div>
<div class="footer"></div>
</div>
.container {width:960px; margin:0 auto;}
.header {width:960px; height:150px; oveflow:hidden; text-indent:-999px;}
.menu {width:960px; height:30px;}
.menu li {float:left; width....; height:30px;}
.menu li a {display:block; width:100%; height:30px; overflow:hidden; text-indent:-999px;}
.content {width:960px;}
.footer {width:960px; clear:both; height:100px;}
Tak naprawdę width nie będzie potrzebny, bo te elementy są typu block czyli mają width 100%.
Ogólnie najlepiej stosować właśnie taką konstrukcję. To taka baaardzo ogólna struktura.
Jezeli jednak masz umieszczony h1 jako oddzielny element, wtedy centrujesz go
margin:0 auto
Piewsza wartość to y, druga to x. Jeżeli ustawiona jest na auto - wtedy centruje dany element. Ale tylko wtedy gdy ma on ustawioną szerokość.