有人可以告诉我为什么IE 6 div不在中心。我用margin:0 auto;问题仅出现在IE 6中!
HTML
<div id="center">
<div id="top_menu">
<a href="/Default.aspx">Domov</a>
· <a href="/EnterSite.aspx">Vpišite stran</a>
· <a href="/About.aspx">O nas</a>
· <a href="/Help.aspx">Pomoč pri iskanju</a>
· <a href="/Marketing.aspx">Oglaševanje</a>
· <a href="/Info.aspx">Splošni pogoji in pravila</a>
</div>
<a href="http://www.viamura.si"><img src="/images/viamura_logo.png" width="294" height="95" border="0" alt="viamura" /></a>
<div id="tabs">
<ul>
<li><asp:LinkButton ID="btnWeb" runat="server" CssClass="web_selected"
onclick="btnWeb_Click">Web</asp:LinkButton></li>
<li><asp:LinkButton ID="btnMap" runat="server" CssClass="map"
onclick="btnMap_Click">Zemljevidi</asp:LinkButton></li>
<li><asp:LinkButton ID="btnWeather" runat="server" CssClass="weather"
onclick="btnWeather_Click">Vreme</asp:LinkButton></li>
<li><asp:LinkButton ID="btnImages" runat="server" CssClass="images"
onclick="btnImages_Click">Slike</asp:LinkButton></li>
<li><asp:LinkButton ID="btnConverter" runat="server" CssClass="converter"
onclick="btnConverter_Click">Converter</asp:LinkButton></li>
</ul>
</div>
CSS:
#center {
width:520px;
margin:0 auto;
}
#tabs {
width:400px;
margin:0 auto;
}
#tabs ul li a.web,#tabs ul li a.map,#tabs ul li a.weather,#tabs ul li a.images,#tabs ul li a.converter,#tabs ul li a.web_selected,#tabs ul li a.map_selected,#tabs ul li a.weather_selected,#tabs ul li a.images_selected,#tabs ul li a.converter_selected {
background-color:#0C0;
float:left;
height:18px;
text-indent:-9999px;
}
#tabs ul {
float:left;
width:459px;
margin:10px 0 0 41px;
}
#tabs ul li {
float:left;
margin:0 2px 0 0;
}
#tabs ul li a.web {
background:url(../images/tab_web.png) no-repeat;
width:46px;
}
#tabs ul li a.map {
background:url(../images/tab_map.png) no-repeat;
width:80px;
}
#tabs ul li a.weather {
background:url(../images/tab_weather.png) no-repeat;
width:58px;
}
#tabs ul li a.images {
background:url(../images/tab_images.png) no-repeat;
width:48px;
}
#tabs ul li a.converter {
background:url(../images/tab_converter.png) no-repeat;
width:78px;
}
#tabs ul li a.web_selected {
background:url(../images/tab_web_selected.png) no-repeat;
width:46px;
}
#tabs ul li a.map_selected {
background:url(../images/tab_map_selected.png) no-repeat;
width:80px;
}
#tabs ul li a.weather_selected {
background:url(../images/tab_weather_selected.png) no-repeat;
width:58px;
}
#tabs ul li a.images_selected {
background:url(../images/tab_images_selected.png) no-repeat;
width:48px;
}
#tabs ul li a.converter_selected {
background:url(../images/tab_converter_selected.png) no-repeat;
width:78px;
}
答案 0 :(得分:0)
你需要把
text-align: center
位于body
或div
div附近的center
。
body
{ text-align: center; }
为防止所有子元素也具有居中文本,您必须重置text-align:
#center {
width:520px;
margin:0 auto;
text-align: left;
}