gpt4 book ai didi

HTML 和 CSS - 将标题中的文本居中在 Logo 和按钮之间

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

我如何才能将我的导航链接与标题对齐?这是我目前拥有的:Link between logo and button但是,我真的很想让链接在标题中垂直对齐,如下所示:Wanted result.我该怎么做?下面是我的 CSS 和 HTML。

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

body {
font-family: 'Open Sans', sans-serif;
}

.wrapper {
width: 1100px;
max-width: 90%;
margin: 0 auto;
}

#top_header {
position: fixed;
left: 0px;
top: 0px;
right: 0px;
background-color: #26ABF5;
height: 70px;
vertical-align: middle;
}

#logo_top {
display: inline-block;
width: 53px;
padding-top: 8px;
}

#main_nav {
display: inline-block;
font-size: 12px;
padding-left: 170px;
}

#main_nav a {
color: #fff;
font-weight: 400;
text-decoration: none;
margin-left: 6em;
}

.button {
float: right;
justify-content: center;
display: flex;
width: 101px;
margin-top: 14px;
padding-top: 9px;
padding-bottom: 9px;
border-radius: 2px;
background-color: #fff;
text-decoration: none;
font-family: 'Open Sans', sans-serif;
color: #26abf5;
font-size: 13px;
font-weight: 600;
}
<body>
<header id="top_header">
<div class="wrapper">
<a href="index.html"><img id="logo_top" draggable="false" src="images/logo1.png"></a>
<nav id="main_nav">
<a href="#">FORSIDE</a>
<a href="#">HVAD TILBYDER VI?</a>
<a href="#">PRISER</a>
<a href="#">OM OS</a>
</nav>
<a class="button" href="#">LOG IND</a>
</div>
</body>

最佳答案

vertical-align 使用行高。我在 #main_nav 中添加了这一行。

编辑为您的 Logo 图片添加float: left;

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

body {
font-family: 'Open Sans', sans-serif;
}

.wrapper {
width: 1100px;
max-width: 90%;
margin: 0 auto;
}

#top_header {
position: fixed;
left: 0px;
top: 0px;
right: 0px;
background-color: #26ABF5;
height: 70px;
vertical-align: middle;
}

#logo_top {
display: inline-block;
float: left;
width: 53px;
padding-top: 8px;
}

#main_nav {
display: inline-block;
font-size: 12px;
line-height: 70px;
padding-left: 170px;
}

#main_nav a {
color: #fff;
font-weight: 400;
text-decoration: none;
margin-left: 6em;
}

.button {
float: right;
justify-content: center;
display: flex;
width: 101px;
margin-top: 14px;
padding-top: 9px;
padding-bottom: 9px;
border-radius: 2px;
background-color: #fff;
text-decoration: none;
font-family: 'Open Sans', sans-serif;
color: #26abf5;
font-size: 13px;
font-weight: 600;
}
<body>
<header id="top_header">
<div class="wrapper">
<a href="index.html"><img id="logo_top" draggable="false" src="images/logo1.png"></a>
<nav id="main_nav">
<a href="#">FORSIDE</a>
<a href="#">HVAD TILBYDER VI?</a>
<a href="#">PRISER</a>
<a href="#">OM OS</a>
</nav>
<a class="button" href="#">LOG IND</a>
</div>
</body>

关于HTML 和 CSS - 将标题中的文本居中在 Logo 和按钮之间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40193920/

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