我有一個菜單欄在屏幕上居中。在左邊,我有一個元素以及一個右邊的元素。這些背景圖像將菜單欄與圖形佈局的其餘部分相關聯。如何在保留文本對齊的同時去除2個元素之間的空白區域?
的問題是,有標記之間的空格。這裏是CSS:
#menu_items {
display: inline-block;
position: relative;
margin: 0;
padding: 6px;
top: -9px;
height: 15px;
background-color: #75784D;
}
#swoop_left {
position: relative;
display: inline-block;
margin: 0;
padding: 0;
background-image: url('../imgs/menu_l.gif');
background-repeat: no-repeat;
width: 140px;
height: 21px;
font-size: 0px;
border: solid red 1px;
}
#swoop_right {
position: relative;
display: inline-block;
margin: 0;
padding: 0;
background-image: url('../imgs/menu_r.gif');
background-repeat: no-repeat;
width: 140px;
height: 21px;
border: solid red 1px;
}
圖片本身是140px X 21px(寬x高)。
我不能浮動它們,因爲菜單將不會中心。我不能在父容器上使用
font-size: 0px;
,因爲它不會顯示菜單項,並設置菜單項來
font-size: 1em;
事後不能解決問題。
任何人有一個解決方案,將在所有的瀏覽器和不依賴於JS?
注:這兩個元素的邊框僅用於佈局的目的,並不會在最後的代碼。
你能解釋一下標籤是什麼嗎? 「標籤之間有空格」 – 2012-03-04 05:56:40
您能否顯示相關標記? – nnnnnn 2012-03-04 05:57:00