我試圖創建一個導航欄,其中包含四個元素,兩個較小的按鈕將鏈接到主頁和一個聯繫頁面,然後兩個更大的按鈕將鏈接到該網站的兩個主要部分。我試圖以兩個大按鈕居中的方式來定位事物,左邊有兩個較小的按鈕。CSS導航欄 - 基於導航欄內元素的居中
我不能「保證金:0汽車;」他們自己的div內的兩個大按鈕,因爲我必須將其設置爲「display:block;」它將它們設置在與較小按鈕不同的行上,並且一旦瀏覽器窗口發生更改,就會絕對定位事物。
我覺得我在這裏錯過了一些簡單的東西。我從錯誤的角度來看這個嗎?
這裏是什麼,我目前所面對的一個Dabblet ... http://dabblet.com/gist/6287837
HTML
<div id="nav-container">
<div id="small-button-container">
<img src="http://placehold.it/47x22" class="small-button01" />
<img src="http://placehold.it/70x42" class="small-button02" />
</div>
<div id="big-button-container">
<img src="http://placehold.it/360x64" />
<img src="http://placehold.it/360x64" />
</div>
</div>
CSS
#nav-container{
outline: 1px red dashed;
width: 1000px;
display: block;
margin: 0 auto;}
#small-button-container{
display: inline-block;
width: 136px;
position: relative;
top: -22px;
left: 40px;}
#big-button-container{
display: inline-block;
width: 780px;
height: 64px;
margin-left: 70px;}
.small-button01{
display: inline;
position: relative;
left: 5px;}
.small-button02{
display: inline;
position: relative;
left: 15px;}
在這裏,你去。 http://dabblet.com/gist/6288178。請注意,這些小按鈕沒有足夠的空間 – Itay