gpt4 book ai didi

html - 居中文本和导航对齐

转载 作者:行者123 更新时间:2023-11-28 09:05:31 24 4
gpt4 key购买 nike

我下面有一个标题和一个导航,我无法将它们对齐到 div 的中心...我希望“Onze producten”成为标题,然后导航菜单对齐标题下的中心。想不通怎么办

这就是我想要的样子......

enter image description here

HTML:

<div class="section2">
<div class="content2">
<p><span style="font-size:30px; color:#fdd400">Onze producten</span></p>
<ul id="nav2">
<li class="active">Particulier</li>
<li>Zakelijk</li>
<li>Alle producten ></li>
<div class="clearfix"></div>
</ul>
</div>
</div>

CSS:

.section2
{
position:relative;
width:100%;
height:700px;
border:1px solid black;
text-align:center;
}
.content2
{
height: 110px;
border:1px solid red;
}
#nav2
{
list-style: none outside none;
font-size:16px;
position:absolute;
margin-left:14.5%;
margin-top:-17px;
color:#6e6e6e;
}
#nav2 li
{
border-bottom: 2px solid #DDDDDD;
cursor: pointer;
float: left;
margin: 0;
width:160px;
height:50px;
line-height:50px;
position: relative;
text-align:center;
}
.clearfix
{
clear: both;
}
#nav2 li:hover:after, #nav2 li.active:after
{
border: 1px solid #044584;
bottom: 0;
content: "";
left: 0;
position: absolute;
width: 160px;
}
.active
{
color:#044584;
font-weight: bold;
}

最佳答案

希望这对您有所帮助:) http://jsfiddle.net/matjazmav/hgto6qhe/3/

#nav2 
{
list-style: none outside none;
font-size:16px;
margin-left:14.5%;
margin-top:-17px;
color:#6e6e6e;

list-style-type: none;
padding:0;
margin:0;
display:inline-block;
}

同时将高度编辑为 120:

.content2
{
height: 120px;
border:1px solid red;
}

关于html - 居中文本和导航对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26723635/

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