gpt4 book ai didi

html - 无法在容器中定位主菜单

转载 作者:太空宇宙 更新时间:2023-11-03 23:54:25 25 4
gpt4 key购买 nike

我正在尝试为页面创建布局,但我遇到了问题。

为什么水平主菜单(.logoc 旁边的#main_menu)放置在容器底部?它应该在中间。

HTML:

<div class="content_wrapper">
<div id="top_info">
<ul class="hor_list" id="lang_menu">
<li><a href="#">Finland</a>
</li>
</ul>
</div>
</div>
<div id="header_wrapper">
<div class="content_wrapper">
<div id="header">
<div class="logo"></div>
<ul class="hor_list" id="main_menu">
<li><a href="#">Home</a></li>
</ul>
</div>
</div>
</div>

CSS:

 html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
/* apply a natural box layout model to all elements */
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* CSS */
.content_wrapper {
width: 1000px;
margin: 0 auto;
}
#top_info {
width: 1000px;
margin: 0 auto;
height: 53px;
line-height: 53px;
}
#header_wrapper {
background: black;
width: 100%;
height: 82px;
}
#header {
height: 82px;
width: 1000px;
background: #FF6633;
}
.logo {
width: 131px;
height: 82px;
background: url('img/logo.png') no-repeat;
display: inline-block;
}
.hor_list {
display: inline-block;
}
.hor_list li {
display:inline;
}
.hor_list li a {
display: inline-block;
}
#main_menu {
line-height: 82px;
}

这是 jsfiddle 工作示例:http://jsfiddle.net/T9qpQ/

最佳答案

http://jsfiddle.net/T9qpQ/3/

只需要做 vertical-align: top;

.hor_list {
display: inline-block;
vertical-align: top;
}

关于html - 无法在容器中定位主菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19094353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com