gpt4 book ai didi

html - 网页标题问题

转载 作者:行者123 更新时间:2023-11-28 00:21:12 25 4
gpt4 key购买 nike

我正在创建一个网站,但遇到了一些标题/导航问题。我已经将网站居中(工作正常)并且我的标题从它应该在页面上的位置开始但是当我向标题添加边框底部时它从它应该的位置开始但继续到页面的右侧。我的导航栏(它是一个 float: right)也从网页的最右侧开始。接下来是 HTML 和 CSS。我知道这可能很明显,但我不知所措。

html,
body {
padding: 0;
margin: 0;
}

html {
background-color: #FFF;
max-width: 100%;
}

body {
margin-left: auto;
margin-right: auto;
width: 1024px;
background-color: #FFF;
font-family: 'Merriweather', serif;
font-family: 'Playfair Display', serif;
}

header {
height: 6em;
border-bottom: 1px solid #00529C;
position: fixed;
display: block;
overflow: hidden;
width: 100% !important;
z-index: 1;
}

nav {
max-width: 50%;
}

.hdrmenu ul {
margin-right: 1em;
padding-top: 1.5em;
}

.hdrmenu li {
float: left;
list-style: none;
/*margin: auto;*/
}

.hdrmenu li a {
text-align: center;
text-decoration: none;
padding: 0em 2em;
/*list-style: none;*/
overflow: hidden;
color: #00529C;
}
<header class="bg transition">
<nav class="hdrmenu">
<a href="index.html"><img src="_images/1280_AcYxdW7KNtA0.png" class="logo"></a>
<ul style="float: right;">
<li><a href="ardvark.html" class="slide-left-right">Ardvark</a></li>
<li><a href="beaver.html" class="slide-left-right">Beaver</a></li>
<li><a href="cougar.html" class="slide-left-right">Cougar</a></li>
<li><a href="dinosaur.html" class="slide-left-right">Dinosaur</a></li>
<li><a href="elephant.html" class="slide-left-right">Elephant</a></li>
</ul>
</nav>
</header>

<section class="mainContent">
<h1>Animals</h1>
<p>Blah, Blah</p>
</section>

最佳答案

给你:

html,
body {
padding: 0;
margin: 0;
}

body {
font-family: 'Merriweather', serif;
font-family: 'Playfair Display', serif;
}

header,
.mainContent {
width: 1024px;
}

.mainContent {
margin: 120px auto 0;
}

header {
height: 6em;
border-bottom: 1px solid #00529C;
position: fixed;
z-index: 1;
background-color: #FFFFFF;
margin: 0 50%;
transform: translateX(-50%);
top: 0;
left: 0;
}

.hdrmenu ul {
margin-right: 1em;
padding-top: 1.5em;
}

.hdrmenu li {
float: left;
list-style: none;
}

.hdrmenu li a {
text-align: center;
text-decoration: none;
padding: 0em 2em;
overflow: hidden;
color: #00529C;
}

关于html - 网页标题问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54857597/

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