Подскажите как выровнять елементы в header?

У меня не работают стили для .header, и не могу понять откуда появился лишний отступ в навигации

html,
body {
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  color: #555;
  font-size: 16px;
  flex-direction: row;
  flex-shrink: 1;
  flex-wrap: wrap;
}
* {
  box-sizing: border-box;
}
.main {
  display: flex;
  min-height: 100vh;
}
.header {
  display: flex;
  text-align: center;
  justify-content: center;
  font-family: Arial, Helvetica, sans-serif;
  background-image: linear-gradient(60deg, red, orange);
  color: white;
  flex-grow: 1;
}
.navigation {
  max-width: 20%;
  margin: 0;
  padding: 0;
}
.nav-list {
  display: flex;
  flex-direction: column;
  line-height: 2em;
}
.nav-list-item {
  margin-bottom: 0.5em;
  background-color: #808080;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: white;
  min-width: 100%;
}
.nav-list-link {
  text-decoration: none;
  list-style-type: none;
  color: white;
}
section > .section_header {
  font-size: 5vw;
}
.section {
  display: flex;
  flex-direction: column;
  width: 60%;
  line-height: 1.75em;
  font-size: 1.25em;
}
.css-units {
  color: #8b0000;
  background-color: #e5e5e5;
  font-size: 1.125em;
  font-weight: 700;
}
footer {
  text-align: center;
  background-color: #e5e5e5;
  padding: 0.5em;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css"
      integrity="sha256-WAgYcAck1C1/zEl5sBl5cfyhxtLgKGdpI3oKyJffVRI="
      crossorigin="anonymous"
    />
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <header class="header">
      <h1>Responsive website</h1>
    </header>
    <main class="main">
      <nav class="navigation">
        <ul class="nav-list">
          <li class="nav-list-item"><a class="nav-list-link" href="#">Responsive images</a></li>
          <li class="nav-list-item"><a class="nav-list-link" href="#">Mediaqueries</a></li>
          <li class="nav-list-item"><a class="nav-list-link" href="#">Flexbox</a></li>
        </ul>
      </nav>
      <section class="section">
        <h2 class="section__header">True story</h2>
        <p>There are few ways to define <code>font-size</code>:</p>
        <ul class="units-list">
          <li>
            <span class="css-units">px</span> are good if you need strict definition for a size of
            text. In other cases it is better to use relative units listed below.
          </li>
          <li><span class="css-units">em</span> based on current font size</li>
          <li><span class="css-units">rem</span> based on <code>&lt;html&gt;</code> font-size</li>
          <li><span class="css-units">%</span> based on parent font size</li>
          <li><span class="css-units">vh</span> (viewport height) based on screen height</li>
          <li><span class="css-units">vw</span> (viewport width) based on screen width</li>
        </ul>
      </section>
      <aside class="news">
        <h2>Not a news</h2>
        <p>A web page should look good on any device!</p>
      </aside>
    </main>
    <footer class="footer">Welcome to the responsive world!</footer>
  </body>
</html>


Ответы (1 шт):

Автор решения: Проста Miha

Добавьте стиль margin: 0;padding: 0; для вашего ul.nav-list.
Для списка в HTML по-умолчанию стоит margin и padding.

А что вам не нравиться в header я не понимаю, стиль применяется, всё работает, что вас не устраивает?

html,
body {
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  color: #555;
  font-size: 16px;
  flex-direction: row;
  flex-shrink: 1;
  flex-wrap: wrap;
}

* {
  box-sizing: border-box;
}

.main {
  display: flex;
  min-height: 100vh;
}

.header {
  display: flex;
  text-align: center;
  justify-content: center;
  font-family: Arial, Helvetica, sans-serif;
  background-image: linear-gradient(60deg, red, orange);
  color: white;
  flex-grow: 1;
}

.navigation {
  max-width: 20%;
  margin: 0;
  padding: 0;
}

.nav-list {
  display: flex;
  flex-direction: column;
  line-height: 2em;
  margin: 0;
  padding: 0;
}

.nav-list-item {
  margin-bottom: 0.5em;
  background-color: #808080;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: white;
  min-width: 100%;
}

.nav-list-link {
  text-decoration: none;
  list-style-type: none;
  color: white;
}

section>.section_header {
  font-size: 5vw;
}

.section {
  display: flex;
  flex-direction: column;
  width: 60%;
  line-height: 1.75em;
  font-size: 1.25em;
}

.css-units {
  color: #8b0000;
  background-color: #e5e5e5;
  font-size: 1.125em;
  font-weight: 700;
}

footer {
  text-align: center;
  background-color: #e5e5e5;
  padding: 0.5em;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css" integrity="sha256-WAgYcAck1C1/zEl5sBl5cfyhxtLgKGdpI3oKyJffVRI=" crossorigin="anonymous" />
  <link rel="stylesheet" href="styles.css" />
</head>

<body>
  <header class="header">
    <h1>Responsive website</h1>
  </header>
  <main class="main">
    <nav class="navigation">
      <ul class="nav-list">
        <li class="nav-list-item"><a class="nav-list-link" href="#">Responsive images</a></li>
        <li class="nav-list-item"><a class="nav-list-link" href="#">Mediaqueries</a></li>
        <li class="nav-list-item"><a class="nav-list-link" href="#">Flexbox</a></li>
      </ul>
    </nav>
    <section class="section">
      <h2 class="section__header">True story</h2>
      <p>There are few ways to define <code>font-size</code>:</p>
      <ul class="units-list">
        <li>
          <span class="css-units">px</span> are good if you need strict definition for a size of text. In other cases it is better to use relative units listed below.
        </li>
        <li><span class="css-units">em</span> based on current font size</li>
        <li><span class="css-units">rem</span> based on <code>&lt;html&gt;</code> font-size</li>
        <li><span class="css-units">%</span> based on parent font size</li>
        <li><span class="css-units">vh</span> (viewport height) based on screen height</li>
        <li><span class="css-units">vw</span> (viewport width) based on screen width</li>
      </ul>
    </section>
    <aside class="news">
      <h2>Not a news</h2>
      <p>A web page should look good on any device!</p>
    </aside>
  </main>
  <footer class="footer">Welcome to the responsive world!</footer>
</body>

</html>

→ Ссылка