Search code examples
htmlcssnavigationnav

A button is inside the navigation bar, but the btn doesnt belong in the div class of the nav bar


So I made a post similar to this one, since I didn't get a precise answer and didn't understand the instructions. So I am once again asking for your support.

There are a couple of issues regarding my nav bar that I am unable to fix. One of them is a button sticking inside of the nav bar, but it doesn't even belong in the div class.

Navigation Bar

enter image description here

The second issue is that I can't line the logo/text [SINUS] and the links together in one line. Any help would be appreciated!

/*====================
   The CSS File   
     Section 1:
      Buttons       
=====================*/

button {
  background-color: #358cf0;
  border: none;
  border-radius: 18px;
  text-align: center;
  text-decoration: none;
  opacity: 0.8;
  font-size: 14px;
  color: rgb(255, 255, 255);
  padding: 12px 48px;
  transition: 0.3s;
  outline: none;
}

button:hover {
  opacity: 1;
}

ul li {
  display: inline-block;
  padding: 10px;
  font-size: 20px;
  font-family: raleway;
}

ul li:hover {
  color: orange;
}


/*====================
   The CSS File   
     Section 2:
      Alerts       
=====================*/

.container {
  position: fixed;
  top: 74%;
  right: 0;
  left: 77%;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: basic;
}

.modal {
  width: 40%;
  min-width: 20rem;
  background-color: #ffffff;
  border-radius: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  background-color: #358cf0;
  padding: 8px 10px;
  color: #fff;
  font-size: 110%;
  font-weight: 600;
  font-family: basic;
}

.modal-content {
  padding: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.modal-footer {
  text-align: center;
}


/*====================
   The CSS File   
     Section 3:
      Body etc.       
=====================*/

body {
  background-color: #252036;
}

#navigation-container {
  width: 1200px;
  margin: 0 auto;
  height: 70%;
}

.navigation-bar {
  background-color: #1c172c;
  position: fixed;
  width: 100%;
  left: 0;
  top: 0;
  text-align: right;
}

.navigation-bar ul {
  padding: 0px;
  margin: 0px;
  text-align: right;
  display: inline-block;
  vertical-align: top;
}

.navigation-bar li {
  list-style-type: none;
  padding: 0px;
  display: inline;
  text-align: right;
}

.navigation-bar li a {
  color: black;
  font-size: 16px;
  font-family: basic;
  text-decoration: none;
  line-height: 70px;
  padding: 5px 15px;
  opacity: 0.7;
}

#menu {
  float: right;
}


/*====================
   The CSS File   
     Section 4:
        Text       
=====================*/

@font-face {
  font-family: basic;
  src: url(Helmet-Regular.ttf);
}

h1 {
  font-family: basic;
  color: white;
  font-size: 390%;
  text-align: left;
}
<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" type="text/css" href="sccp.css">
  <title>Sinus - 【Home】</title>
  <link rel="icon" href="titl.ico">
  <link rel="apple-touch-icon" href="titl.ico" />
</head>

<body>
  <div class="navigation-bar">
    <div id="navigation-container">
      <h1>SINUS</h1>
      <ul>
        <li><a href="#">Home</a></li>
      </ul>
    </div>
  </div>
  <button>Download</button>
  <div class="container" role="alert">

    <div class="modal">
      <div class="modal-header">
        UPDATE! Sinus 1.0v
      </div>
      <div class="modal-content">
        Here new stuff go gogogo
        <br><a href="#">Read more...</a>
      </div>
      <div class="modal-footer">

      </div>
    </div>

  </div>

</body>

</html>


Solution

  • To align the logo and links, use flex on the #navigation-container:

    #navigation-container {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    

    justify-content: space-between will put the maximum space between the contents - in this case your logo and ul that contain the links. align-items:center lines them up vertically.

    https://codepen.io/doughballs/pen/RwPrYoX

    Not sure what your issue with the button is but because your nav has position:fixed, it is being taken out of the flow of the page, so the button doesn't 'know' it is there. If you wanted it to sit under the nav, you need to add a container with margin-top to push it down. But I'm not sure what your issue is with it, clarify and I'll amend the codepen.