gpt4 book ai didi

html - 我如何让我的链接靠近 Logo ?

转载 作者:行者123 更新时间:2023-11-28 03:40:14 25 4
gpt4 key购买 nike

我希望导航栏中的链接位于 Logo 旁边,并在右侧获得另一个链接 - 不在其他链接旁边 - 写着“文本”。我想要对解决方案的解释,因为如果我再次偶然发现这个问题,它会对我有所帮助。顺便说一句,我对 stackoverflow 很陌生。

body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
margin: 0;
padding: 0;
}

p {
margin: 0;
padding: 0;
}

.container {
width: 80%;
margin: auto;
overflow: hidden
}

header {
background-color: #191919;
position: fixed;
width: 100%;
float: left;
color: #edf9ff;
min-height: 70px;
border-bottom: #0fe216 3px solid;
display: flex;
align-items: center;
justify-content: space-between;
}

header a {
text-decoration: none;
text-transform: uppercase;
color: #edf9ff;
}

a:hover {
color: blue;
}

header ul {
margin: 0;
}

header li {
list-style-type: none;
float: left;
padding-right: 20px;
}

#showcase {
padding-top: 100px;
height: 750px;
width: 100%;
background-image: url(./images/BackgroundShowcase.jpg);
background-size: 100% 100%;
}

#showcase h2 {
font-size: 50px;
color: green;
text-align: center;
}

#showcase p {
font-size: 20px;
color: green;
text-align: center;
}

#slideshow {
position: relative;
top: 350px;
}

#slideshow .Slides {
width: 200px;
padding-right: 15%;
height: 200px;
}

.boxes {
margin-top: 50px;
margin-bottom: 50px;
}

.box {
width: 30%;
float: left;
text-align: center;
}

.box img {
width: 175px;
height: 150px;
}

footer {
background-color: #191919;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
clear: left;
}

footer p {
text-align: center;
color: white;
}
<!doctype html>
<html>

<head>
<title>Mukhtar's Photography | Home </title>
<link href="Home.css" rel="stylesheet" />
<script type="application/javascript" src="Home.js"></script>
</head>

<body>

<header>
<div id="branding">
<h2>PHOTOGRAPHY</h2>
</div>
<nav id="links">
<ul>
<li><a href="Home.html">Home</a></li>
<li><a href="About.html">About</a></li>
<li><a href="PhotoGallery.html">PHOTO GALLERY</a></li>
<li><a href="#">VIDEO GALLERY</a></li>
</ul>
</nav>
</header>
<section id="showcase">
<div class="container">
<h2>Photography</h2>
<p>Our photo's are always presente in the best quality possible with carefulness
</p>
</div>
</section>
<section class="boxes">
<div class="box">
<img src="./images/CameraIcon.png">
<h2>Photography</h2>
<p>Our photographers will always find the perfect photo whether it is a simple click to a full on video</p>
</div>
<div class="box">
<img src="./images/CommunityICON.jpg">
<h2>Guranteed!</h2>
<p>If you are not satisfied with our work you will have an 80% refund</p>


</div>
<div class="box">
<img src="./images/TimeIcon.png">
<h2>Time Managment</h2>
<p>Time management is a crucial step so we are always trying our best to finish up the work quickly, but surely</p>
</div>
</section>
<footer>
<p>Note that any copyright &copy; is reserved</p>
</footer>
</body>

</html>

最佳答案

你可以简单地将 logo 和 nav 包裹在一个新元素 (.d-inline-block) 中,将其设置为 display: inline-flex (这将把logo 和 nav 排成一排),然后在页眉中添加一个链接。由于 header 是 display: flex; justify-content: space-between; Logo 和导航将位于一个元素的左侧,该元素位于左侧,新的“文本”链接将位于右侧。

body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
margin: 0;
padding: 0;
}

p {
margin: 0;
padding: 0;
}

.container {
width: 80%;
margin: auto;
overflow: hidden
}

header {
background-color: #191919;
position: fixed;
width: 100%;
float: left;
color: #edf9ff;
min-height: 70px;
border-bottom: #0fe216 3px solid;
display: flex;
align-items: center;
justify-content: space-between;
}

header a {
text-decoration: none;
text-transform: uppercase;
color: #edf9ff;
}

a:hover {
color: blue;
}

header ul {
margin: 0;
}

header li {
list-style-type: none;
float: left;
padding-right: 20px;
}

#showcase {
padding-top: 100px;
height: 750px;
width: 100%;
background-image: url(./images/BackgroundShowcase.jpg);
background-size: 100% 100%;
}

#showcase h2 {
font-size: 50px;
color: green;
text-align: center;
}

#showcase p {
font-size: 20px;
color: green;
text-align: center;
}

#slideshow {
position: relative;
top: 350px;
}

#slideshow .Slides {
width: 200px;
padding-right: 15%;
height: 200px;
}

.boxes {
margin-top: 50px;
margin-bottom: 50px;
}

.box {
width: 30%;
float: left;
text-align: center;
}

.box img {
width: 175px;
height: 150px;
}

footer {
background-color: #191919;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
clear: left;
}

footer p {
text-align: center;
color: white;
}

.d-inline-flex {
display: inline-flex;
align-items: center;
}
<!doctype html>
<html>

<head>
<title>Mukhtar's Photography | Home </title>
<link href="Home.css" rel="stylesheet" />
<script type="application/javascript" src="Home.js"></script>
</head>

<body>

<header>
<div class="d-inline-flex">
<div id="branding">
<h2>PHOTOGRAPHY</h2>
</div>
<nav id="links">
<ul>
<li><a href="Home.html">Home</a></li>
<li><a href="About.html">About</a></li>
<li><a href="PhotoGallery.html">PHOTO GALLERY</a></li>
<li><a href="#">VIDEO GALLERY</a></li>
</ul>
</nav>
</div>
<a href="#">text</a>
</header>
<section id="showcase">
<div class="container">
<h2>Photography</h2>
<p>Our photo's are always presente in the best quality possible with carefulness
</p>
</div>
</section>
<section class="boxes">
<div class="box">
<img src="./images/CameraIcon.png">
<h2>Photography</h2>
<p>Our photographers will always find the perfect photo whether it is a simple click to a full on video</p>
</div>
<div class="box">
<img src="./images/CommunityICON.jpg">
<h2>Guranteed!</h2>
<p>If you are not satisfied with our work you will have an 80% refund</p>


</div>
<div class="box">
<img src="./images/TimeIcon.png">
<h2>Time Managment</h2>
<p>Time management is a crucial step so we are always trying our best to finish up the work quickly, but surely</p>
</div>
</section>
<footer>
<p>Note that any copyright &copy; is reserved</p>
</footer>
</body>

</html>

关于html - 我如何让我的链接靠近 Logo ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44251184/

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