Home > Blockchain >  HTML tag not spreading out on the page
HTML tag not spreading out on the page

Time:12-28

I startd today on a new portfolio website. The navigation is done and now I wanna start on the actual website But everything that I type stands above my name (the logo)

This is what I wanna build:the idea But this is what comes out: what comes out

If you inspect it, it says that the whole navigation part is the html tag. Here is the code:

a {
  text-decoration: none;
  font-weight: bold;
}

.nav-name {
  font-size: 27px;
  margin-left: 75px;
  margin-top: 10px;
  float: left;
}

.nav-item {
  list-style: none;
  float: right;
  margin-left: 35px;
  margin-right: 10px;
  font-size: 18px;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
  <script src="https://kit.fontawesome.com/aab1cdc4fa.js" crossorigin="anonymous"></script>
  <title>Floris M portfolio</title>
</head>

<body>
  <header  id="header">
    <nav>
      <div >
        <a href="#" >Floris</a>
      </div>
      <ul >
        <li >
          <a href="#programs">My programs</a>
        </li>
        <li >
          <a href="#projects">My projects</a>
        </li>
        <li >
          <a href="#skils">Skills</a>
        </li>
        <li >
          <a href="#about">About me</a>
        </li>
        <li >
          <a href="#home">Home</a>
        </li>
      </ul>
    </nav>
  </header>
  <main>
    <section  id="home">
      <div >
        <a href="https://github.com/Floris29">
          <i ></i>
        </a>
      </div>
    </section>
  </main>
</body>

</html>

I tried to fix it trough putting </P>'s but that didn't work. When I typed more text I would come out under it but also in the same line. What I wanna try is that its in different sections.

CodePudding user response:

Try to not use float property, checkout flexbox which will help you align stuff much better, here is a quick fix for your example:

a {
  text-decoration: none;
  font-weight: bold;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-name {
  font-size: 27px;
  margin-left: 75px;
  margin-top: 10px;
}

.nav-item {
  list-style: none;
  margin-left: 35px;
  margin-right: 10px;
  font-size: 18px;
  display: flex;
  align-items:center;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
  <script src="https://kit.fontawesome.com/aab1cdc4fa.js" crossorigin="anonymous"></script>
  <title>Floris M portfolio</title>
</head>

<body>
  <header  id="header">
    <nav>
      <div >
        <a href="#" >Floris</a>
      </div>
      <ul >
        <li >
          <a href="#programs">My programs</a>
        </li>
        <li >
          <a href="#projects">My projects</a>
        </li>
        <li >
          <a href="#skils">Skills</a>
        </li>
        <li >
          <a href="#about">About me</a>
        </li>
        <li >
          <a href="#home">Home</a>
        </li>
      </ul>
    </nav>
  </header>
  <main>
    <section  id="home">
      <div >
        <a href="https://github.com/Floris29">
          <i ></i>
        </a>
      </div>
    </section>
  </main>
</body>

</html>

  • Related