gpt4 book ai didi

html - 如何删除导航栏上的空白

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

这是我遇到的问题的屏幕截图:

Header

我这辈子都想不出如何删除导航栏两侧的空白区域。我试过将边距和填充设置为 0,但没有奏效。任何帮助将不胜感激。

这是html:

html,
body {
margin: 0;
padding: 0;
height: 100%;
background-image: url("images/bg.jpg");
background-repeat: no-repeat;
background-position: center top;
font-family: Times New Roman;
}

header {
clear: both;
text-align: center;
}

#header img {
height: 40%;
width: 40%;
}

#wrap {
width: 1000px;
margin: auto;
padding: auto;
overflow: auto;
}

ul {
padding: 0;
}

nav ul {
margin: auto;
padding: auto;
list-style-type: none;
background-color: #009BB2;
}

nav li {
display: inline;
padding-left: 10px;
}

nav a {
text-decoration: none;
padding: 5px;
font-family: Times New Roman;
font-size: 25px;
color: maroon;
}

nav a:hover {
color: blue;
}

img.size {
height: 15%;
width: 15%;
padding: 5px;
}

section h1 {
text-align: center;
}

figure {
float: right;
overflow: hidden;
margin: 0px;
padding: 0px;
}
<div id="wrap">
<header>
<div id="header">
<img src="logo.png" alt="The Seasons" />
</div>
<nav>
<ul>
<li><a href="">Fall</a></li>
<li><a href="">Spring</a></li>
<li><a href="">Summer</a></li>
<li><a href="">Winter</a></li>
<li><a href="">Home</a></li>
</ul>

</nav>
</header>

<section>
<h1>The Four Seasons of the Earth</h1>
<figure class="fig">
<img class="size" src="images/fall_front.png" alt="Fall" />
</figure>
<figure class="fig">
<img class="size" src="images/winter_front.png" alt="Winter" />
</figure>

<figure class="fig">
<img class="size" src="images/spring_front.png" alt="Spring" />
</figure>

<figure class="fig">
<img class="size" src="images/summer_front.png" alt="Summer" />
</figure>


</section>



</div>

最佳答案

display: inline-block; 添加到您的 nav ul 选择器中,这将删除两侧的空白。

html,
body {
margin: 0;
padding: 0;
height: 100%;
background-image: url("images/bg.jpg");
background-repeat: no-repeat;
background-position: center top;
font-family: Times New Roman;
}

header {
clear: both;
text-align: center;
}

#header img {
height: 40%;
width: 40%;
}

#wrap {
width: 1000px;
margin: auto;
padding: auto;
overflow: auto;
}

ul {
padding: 0;
}

nav ul {
margin: auto;
padding: auto;
list-style-type: none;
background-color: #009BB2;
display: inline-block;
}

nav li {
display: inline;
padding-left: 10px;
}

nav a {
text-decoration: none;
padding: 5px;
font-family: Times New Roman;
font-size: 25px;
color: maroon;
}

nav a:hover {
color: blue;
}

img.size {
height: 15%;
width: 15%;
padding: 5px;
}

section h1 {
text-align: center;
}

figure {
float: right;
overflow: hidden;
margin: 0px;
padding: 0px;
}
<div id="wrap">
<header>
<div id="header">
<img src="logo.png" alt="The Seasons" />
</div>
<nav>
<ul>
<li><a href="">Fall</a></li>
<li><a href="">Spring</a></li>
<li><a href="">Summer</a></li>
<li><a href="">Winter</a></li>
<li><a href="">Home</a></li>
</ul>
</nav>
</header>

<section>
<h1>The Four Seasons of the Earth</h1>
<figure class="fig">
<img class="size" src="images/fall_front.png" alt="Fall" />
</figure>
<figure class="fig">
<img class="size" src="images/winter_front.png" alt="Winter" />
</figure>

<figure class="fig">
<img class="size" src="images/spring_front.png" alt="Spring" />
</figure>

<figure class="fig">
<img class="size" src="images/summer_front.png" alt="Summer" />
</figure>
</section>
</div>

关于html - 如何删除导航栏上的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42542112/

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