gpt4 book ai didi

html - 试图居中导航栏

转载 作者:太空宇宙 更新时间:2023-11-04 12:09:46 24 4
gpt4 key购买 nike

我在尝试将导航栏置于网页中央时遇到问题。我尝试创建一个包装器 div 使其居中,但它似乎不起作用。在那个 div 中唯一有效的是改变左边距。这是 HTML:

body {
background: #bf5c71 url('body-bg.jpg');
}
.clearfix:after {
display: inline-block;
clear: both;
align-content: center;
}
/*----- Menu Outline -----*/

.menu-wrap {
box-shadow: inset 0px 0 0 rgba(255, 255, 255, 0.00);
-webkit-box-shadow: inset 0px 0 0 rgba(255, 255, 255, 0.00);
display: inline-block;
margin: 0px auto;
}
.menu {
display: inline-block;
margin: auto;
}
.menu li {
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
margin-bottom: 0px;
list-style: none;
font-family: 'Century Gothic';
}
.menu a {
transition: all linear 0.15s;
color: #FF283B;
}
.menu li:hover > a,
.menu .current-item > a {
color: #F5F5F5;
}
.menu .arrow {
font-size: 11px;
line-height: 0%;
}
/*----- Top Level -----*/

.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 18px;
}
.menu > ul > li > a {
padding-top: 2px;
padding-right: 2px;
padding-left: 2px;
padding-bottom: 2px;
display: inline-block;
text-shadow: 0px 0px 0px rgba(0, 0, 0, 0.00);
}
.menu > ul > li:hover > a,
.menu > ul > .current-item > a {
background: F5F5F5;
}
/*----- Bottom Level -----*/

.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 100%;
padding: 3px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.0);
background: 0;
}
.sub-menu li {
display: inline-block;
font-size: 16px;
}
.sub-menu li a {
padding-top: 10px;
padding-right: 20px;
padding-left: 20px;
padding-bottom: 5px;
display: inline-block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #FF283B;
}
img {
border: thin solid #FF283B;
margin-left: 5%;
}
h3 {
margin-top: 3%;
font-size: 24px;
}
.wrapper {
display: inline-block;
margin: 0px auto;
}
<div class="wrapper">
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>
<div align="center"><a href="index.html">Home</a></a>
</div>
</li>
<li>
<div align="center"><a href="#">Projects <span class="arrow">&#9660;</span></a>
<ul class="sub-menu">
<li><a href="iap.html">Image Adaptation</a>
</li>
<li><a href="sonic.html">Sonic Memory</a>
</li>
<li><a href="documentary.html">Documentary Video</a>
</li>
</ul>
</div>
</li>
<li>
<div align="center"><a href="resume.html">Resume</a>
</div>
</li>
<li>
<div align="center"><a href="about.html">About</a>
</div>
</li>
<li>
<div align="center"><a href="contact.html">Contact</a>
</div>
</li>
</ul>
</nav>
</div>
</div>

我似乎唯一能做的就是使用 margin-left 将栏向左移动。

网站:tylerbr.com

最佳答案

这就够了:

  .content {
text-align: center;
}

关于html - 试图居中导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29131671/

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