gpt4 book ai didi

html - 我想在我的 Logo 旁边的标题中显示我的导航栏

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

我为一个学校元素制作了一个网站,想进一步改进设计。我认为 Logo 使标题有点大。所以我想将我的导航栏从标题下方移动到标题内部,以使其看起来更小。就这样。我将在下面发布代码和照片。

这是现在的样子

original

我想要的样子

required

/* -----------------------
Layout
------------------------*/

.container {
max-width: 70em;
margin: 0 auto;
}
.header {
font-family: 'Handlee', cursive;
color: #fff;
background: #7eabac;
padding: 0.5em 0em;
}
.header-heading {
margin: 0;
max-width: 300px;
margin-left: 400px;
max-height: 300px;
}
.nav-bar {
background: #e9f1f1;
padding: 0;
}
.content {
overflow: hidden;
padding: 1em 1.25em;
background-color: #fff;
}
.main,
.zijkant {
margin-bottom: 1em;
}
.footer {
color: #fff;
background: #656565;
padding: 1em 1.25em;
}
/* -----------------------
Navbar
------------------------*/

.nav {
margin: 0;
padding: 0;
list-style: none;
font-family: 'Open Sans Condensed', sans-serif;
}
.nav li {
display: inline;
margin: 0;
}
.nav a {
display: block;
padding: .7em 1.25em;
color: #black;
text-decoration: none;
border-bottom: 1px solid gray;
}
.nav a:link {
color: black;
}
.nav a:visited {
color: black;
}
.nav a:focus {
color: black;
background-color: white;
}
.nav a:hover {
color: black;
background-color: #eededb;
}
.nav a:active {
color: white;
background-color: #f4ebe9;
}
<!DOCTYPE html>
<html lang="nl">

<head>
<link rel="stylesheet" href="etc/css/styles.css">
</head>
<script type="text/javascript">
function zoom() {
document.body.style.zoom = "-20%"
}
</script>

<body onload="zoom()">
<div class="header">
<div class="container">
<img src="etc/img/logo-wec.png" class="header-heading"></img>
</div>
</div>
<div class="nav-bar">
<div class="container">
<ul class="nav">
<li><a class="active" href="index.html">Home</a>
</li>
<li><a href="nieuws.html">Nieuws</a>
</li>
<li><a href="producten.html">Producten</a>
</li>
<li><a href="bestellen.html">ROC</a>
</li>
<li><a href="contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</body>

</html>

最佳答案

将图片容器和导航栏放在同一个容器中:

<div class="header">
<div class="container">
<img src="etc/img/logo-wec.png" class="header-heading"></img>
</div>
<div class="nav-bar">
<div class="container">
<ul class="nav">
<li><a class="active" href="index.html">Home</a>
</li>
<li><a href="nieuws.html">Nieuws</a>
</li>
<li><a href="producten.html">Producten</a>
</li>
<li><a href="bestellen.html">ROC</a>
</li>
<li><a href="contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</div>

使用绝对定位给标题相对位置和导航栏的位置:

.header {
font-family: 'Handlee', cursive;
color: #fff;
background: #7eabac;
padding: 0.5em 0em;
position: relative;
}
.nav-bar{
position: absolute;
right: 0;
top: 0;
bottom: 0;
margin: auto;
height: 50px;//adjust to center vertically
width: 300px;//adjust to your liking
}

您必须为导航栏设置高度以确保它垂直居中

关于html - 我想在我的 Logo 旁边的标题中显示我的导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40781986/

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