Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在重复或100%标题上居中显示徽标和菜单?_Html_Css - Fatal编程技术网

Html 在重复或100%标题上居中显示徽标和菜单?

Html 在重复或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

我有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> // 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@Adiran
width: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%;
}