htmlcsssearch-box

How do I move this search box down?


I'm trying to move the search box down, I already tried adding a margin-top and I also tried adding a padding-top but it won't move. I want it to be positioned vertically in the middle of the blue rectangle. I would also like to change the color of the box and the text to different shades of gray. Help would be much appreciated. Thanks!

header {
    position: fixed; /* Helps us position at the top; header no longer takes up space in the flow of the document */
    top: 0px;
    width: 100%;
    padding: 15px;
    background-color: #693969;
    height: 150px;
    margin: 0;
    opacity: .9;
  }

  header {
    margin: 0;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
  }

  .topnav {
    overflow: hidden;
    background-color: rgb(68, 71, 125);
    width: 1260px;
    float: right;
  }

  .topnav input[type=text] {
    float: right;
    padding: 6px;
    border: none;
    margin-top: 8px;
    margin-right: 16px;
    font-size: 17px;
  }
  
  .topnav a {
    float: right;
    color: #391616;
    text-align: center;
    padding: 20px 40px;
    text-decoration: none;
    font-size: 17px;
  }
  
  .topnav a:hover {
    background-color: rgb(194, 125, 125);
    color: rgb(100, 77, 77);
  }
  
  .topnav a.nav {
    background-color: none;
    color: rgb(120, 42, 42);
  }

  .search {
    margin-top: 16px;
  }
<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="stylesheet" type="text/css" href="indexx.css">
    </head>
    <body>
        <header>
        <div class="topnav">
          <a class="nav" href="#home">home</a>
          <a class="nav" href="#home">home</a>
          <a class="nav" href="#home">home</a>
          <a class="nav" href="#home">home</a>
          <input class="search" type="text" placeholder="Search...">
</div>
</header>
    </body>
</html>


Solution

  • update the following css

    .topnav {
        overflow: hidden;
        background-color: rgb(68, 71, 125);
        width: 1260px;
        float: right;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex-direction: row-reverse;
    }
    .topnav input[type=text] {
        float: right;
        padding: 6px;
        border: none;
        margin-right: 16px;
        font-size: 17px;
        margin: 0;
    }