我希望在我的徽标

时间:2016-11-24 09:07:13

标签: html css navbar nav

我为一个学校项目建立了一个网站,并希望进一步改进设计。我认为徽标使标题有点大。所以我想将导航栏从标题下方移动到标题内部,使其看起来更小。这就是全部。我会在下面发布代码和照片。

现在的样子

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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

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

<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
}

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