Html 在重复或100%标题上居中显示徽标和菜单?
我有HTMLHtml 在重复或100%标题上居中显示徽标和菜单?,html,css,Html,Css,我有HTML <div class="mainwraper" style="width:100%;"> <div class="header1"> div logo left <img src="logo"> // - it sends it pasted to the left sidebar div class right // it send it pasted to the right sidebar
<div class="mainwraper" style="width:100%;">
<div class="header1">
div logo left <img src="logo"> // - it sends it pasted to the left sidebar
div class right // it send it pasted to the right sidebar
</div> // need to center them in the page and keep the repeative effect
<div class="header2" style="width:100%;">
<div class="headbar">
<ul class="menu" style="background:#0099CC;"> … </ul>
</div>
</div>
</div>
我希望它看起来像这样[1]:“工具提示”
但它看起来像这样[2]:|工具提示”。
我还想提到的是,在我有了另一个972px的Div类主包装器之后,它正确居中。您可以使用
margin:0 auto;
来居中导航您必须为包装器设置width
,或者您的margin:0 auto;
是meaningless@jasonslyvia它是在HTML@Adiranwidth:100% 表示div没有边距,那么您希望它如何居中?@jasonslyvia您是说我需要在另一个div中包装“mainwrapper”?我建议您可以为您的包装添加minwidth:960px
和width:80%
,当然960px
可以是您想要的任何值
.mainwraper {
margin:0 auto;
}
.header1 {
float:left; width:100%; height:78px; margin-top: 10px;
}
.header2 {
float:left;
width:100%;
position:relative;
z-index:auto;
height:52px;
margin-top:20px;
background: #000;
opacity: 0.65;
border-radius: 10px;
}
.headbar {
background-color: inherit;
float: left;
list-style-type: none;
margin: 0 auto;
padding: 0;
position: relative;
width: 100%;
border-radius: 10px;
}
.menu {
background-color: inherit;
background-image:url(images/menugradient.png);
float: left;
list-style-type: none;
margin: 0 auto;
padding: 0;
position: relative;
width: 100%;
}