<span> column width in a navigation bar

Viewed 104

I'm a complete beginner and I'm trying to make a navigation bar.

I'm trying to make a navigation bar that works and looks like this one from this webpage (different colors): https://www.swiss.com/ch/EN/prepare/check-in

Like this

I've come so far: Mine looks like this

I want each column in .dropdown-content to be the same width as the ones in .column That means the orange column "hello world1" to be the same width as "Category 1" and so forth.

And I also want both columns that are underneath each other to be connected as in the link above. Whenever I hover over the .dropdown-content, I want the background-color of .column to change as well.

Here is my snippet:

* {
      box-sizing: border-box;
    }
    
    body {
      margin: 0;
    }
    
    .navbar {
      overflow: hidden;
      background-color: #333;
      font-family: Arial, Helvetica, sans-serif;
    }
    
    .navbar a {
      float: left;
      font-size: 16px;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
    }
    
    .dropdown {
      float: left;
      overflow: hidden;
    }
    
    .dropdown .dropbtn {
      font-size: 16px;
      border: none;
      outline: none;
      color: white;
      padding: 14px 16px;
      background-color: inherit;
      font: inherit;
      margin: 0;
    }
    
    .navbar a:hover, .dropdown:hover .dropbtn {
      color: #fc7b03;
      background-color: #B5B5B5;
    }
    
    
    .dropdown-content {
      display: none;
      position: absolute;
      background-color: #fc7b03;
      width: 100%;
      left: 0;
      box-shadow: 0px 3px 26px 0px #fc7b03;
      z-index: 1;
      opacity: 95%;
    }
    
    .dropdown-content .header {
      background: red;
      padding: 16px;
      color: white;
    }
    
    .dropdown:hover .dropdown-content {
      display: block;
    }
    
    /* Create three equal columns that floats next to each other */
    .column {
      float: left;
      width: 33.33%;
      padding: 10px;
      background-color: #B5B5B5;
      height: 250px;
     opacity: 100%;
    }
    
    .header2 {
      float: left;
      width: 33.33%;
      padding: 1px;
      background-color: #fc7b03;
      height: 150px;
      opacity: 100%;
      font-size: 12px;
    }
    .header22 {
        float: left;
        position: relative;
      width: 95%;
      margin-left: 2.5%;
      padding: 1px;
      background-color: #fc7b03;
      opacity: 100%;
      font-size: 12px;
    }
    
    .header2:hover {
      background-color: #B5B5B5;
    }
    
    .column a {
      float: none;
      color: black;
      padding: 16px;
      text-decoration: none;
      display: block;
      text-align: left;
    }
    
    .column a:hover {
      background-color: #ddd;
      color: #fc7b03;
    }
    
    /* Clear floats after the columns */
    .row::after {
      content: "";
      display: table;
      clear: both;
    }
    .row2::after {
      content: "";
      display: table;
      clear: both;
    }
    
    /* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
    @media screen and (max-width: 600px) {
      .column {
        width: 100%;
        height: auto;
      }
    }
<link href="/resources/header/header.css" type="text/css" rel="stylesheet">
    
    <body>
      <!--  this is the dropdown navigation panel -->
      <!-- Load font awesome icons -->
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <div class="navbar">
      <a href="#home">Home</a>
      <a href="#news">News</a>
      <div class="dropdown">
        <button class="dropbtn">Dropdown 
          <i class="fa fa-caret-down"></i>
        </button>
        <div class="dropdown-content">
        <div class="row2">
        
       
        <a href="http://google.com">
       
        <img src="https://image.shutterstock.com/image-vector/real-estate-logo-260nw-1615688014.jpg" style="width:50px;  height:50% ">
        <br>
         <span style="display: block" class="header22"> 
        Hello world1
        </span>
        
    </a>
    
        <a href="http://google.com">
        <span style="display: block" class="header22"> 
        Hello world2
        </span>
    </a>
        <a href="http://google.com">
        <span style="display: block" class="header22"> 
        Hello world3
        </span>
    </a>
    -->
     <!--
     <a href="#">
          <div class="header2">
          
            <img src="https://image.shutterstock.com/image-vector/real-estate-logo-260nw-1615688014.jpg" style="width:50px;  height:50% ">
             <h2>Mega Menu</h2>
             
          </div>
          </a>
          <div class="header2">
            <h2 >Mega Menu2</h2>
          </div>
          -->
          </div>
          <div class="row">
            <div class="column">
              <h3>Category 1</h3>
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
            <div class="column">
              <h3>Category 2</h3>
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
            <div class="column">
              <h3>Category 3</h3>
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
          </div>
        </div>
      </div> 
    </div>
    
    <div style="padding:16px">
      <h3>balbllalba</h3>
      <p>Hover over the "Dropdown" link to see the mega menu.</p>
      <p>Re</p>
    </div>
    
    <div style="padding:16px">
      <h3>Responsive Mega Menu (Full-width dropdown in navbar)</h3>
      <p>Hover over the "Dropdown" link to see the mega menu. </p>
    </div>
     </body>

EDIT: I've been able to get a bit further, however i still can't get "Hello world" and "Category 1" to act as one unit under "hover". Not a huge problem, but for now i'm satisfied with what i've got:

* {
      box-sizing: border-box;
    }
    
    body {
      margin: 0;
    }
    
    .navbar {
      overflow: hidden;
      background-color: #333;
      font-family: Arial, Helvetica, sans-serif;
    }
    
    .navbar a {
      float: left;
      font-size: 16px;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
    }
    
    .dropdown {
      float: left;
      overflow: hidden;
    }
    
    .dropdown .dropbtn {
      font-size: 16px;
      border: none;
      outline: none;
      color: white;
      padding: 14px 16px;
      background-color: inherit;
      font: inherit;
      margin: 0;
    }
    
    .navbar a:hover, .dropdown:hover .dropbtn {
      color: #fc7b03;
      background-color: #B5B5B5;
    }
    
    
    .dropdown-content {
      display: none;
      position: absolute;
      background-color: #fc7b03;
      width: 100%;
      left: 0;
      box-shadow: 0px 3px 26px 0px #fc7b03;
      z-index: 1;
      opacity: 95%;
 
    }
    
    .dropdown-content .header {
      background: red;
      padding: 16px;
      color: white;
    }
    
    .dropdown:hover .dropdown-content {
      display: block;
    }
    
    /* Create three equal columns that floats next to each other */
    .column {
      float: left;
      width: 33.33%;
      padding: 10px;
      background-color: #B5B5B5;
      height: 250px;
     opacity: 100%;

    }
    
    .header22 {
      float: left;
      width: 33.33%;
      padding: 1px;
      background-color: #fc7b03;
      height: 150px;
      opacity: 100%;
      font-size: 12px;
   
    }
    .header22s {
        float: left;
        position: relative;
      width: 95%;
      margin-left: 2.5%;
      padding: 1px;
      background-color: #fc7b03;
      opacity: 100%;
      font-size: 12px;
      border: solid;
    }
    
    .header2:hover {
      background-color: #B5B5B5;
    }
    
    .column a {
      float: none;
      color: black;
      padding: 16px;
      text-decoration: none;
      display: block;
      text-align: left;
    }
    
    .column a:hover {
      background-color: #ddd;
      color: #fc7b03;
    }
    
    /* Clear floats after the columns */
    .row::after {
      content: "";
      display: table;
      clear: both;
    }
    .row2::after {
      content: "";
      display: table;
      clear: both;
    }
    
    /* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
    @media screen and (max-width: 600px) {
      .column {
        width: 100%;
        height: auto;
      }
    }

.column:hover , .header22:hover{
  animation-duration: 1.5s;
  animation-name: border;
  animation-iteration-count: infinite;
}
@keyframes border {
  from {

   border: solid white;
   border-width: 2px;
  }

  to {

border: solid #D3CFCF;
border-width: 2px;
  }
}
/* not used stuff 
    .column:hover  {
    background-color: #B5B5B5;
    transition-property: border-color;
    transition-duration: 1.5s;
    border: solid #dbd8cf;
    border-width: 2px;
}
*/
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="navbar">
    <a href="#home">Home</a>
    <a href="#news">News</a>
    <div class="dropdown">
        <button class="dropbtn">Dropdown
            <i class="fa fa-caret-down"></i>
        </button>
        <div class="dropdown-content">
            <div class="row2">


                <a href="http://google.com" class="header22" id="ga">

                    <img src="https://image.shutterstock.com/image-vector/real-estate-logo-260nw-1615688014.jpg"
                        style="width:50px;  height:50% ">
                    <br>
                    <span style="display: block">
                        Hello world1
                    </span>

                </a>

                <a href="http://google.com" class="header22">
                    <span style="display: block">
                        Hello world2
                    </span>
                </a>
                <a href="http://google.com" class="header22">
                    <span style="display: block">
                        Hello world3
                    </span>
                </a>


                <!--
     <a href="#">
          <div class="header2">
          
            <img src="https://image.shutterstock.com/image-vector/real-estate-logo-260nw-1615688014.jpg" style="width:50px;  height:50% ">
             <h2>Mega Menu</h2>
             
          </div>
          </a>
          <div class="header2">
            <h2 >Mega Menu2</h2>
          </div>
          -->
            </div>
            <div class="row">
                <div class="column" id="ga">
                    <h3>Category 1</h3>
                    <a href="#">Link 1</a>
                    <a href="#">Link 2</a>
                    <a href="#">Link 3</a>
                </div>
                <div class="column">
                    <h3>Category 2</h3>
                    <a href="#">Link 1</a>
                    <a href="#">Link 2</a>
                    <a href="#">Link 3</a>
                </div>
                <div class="column">
                    <h3>Category 3</h3>
                    <a href="#">Link 1</a>
                    <a href="#">Link 2</a>
                    <a href="#">Link 3</a>
                </div>
            </div>
        </div>
    </div>
</div>

1 Answers

Here you go!

    * {
      box-sizing: border-box;
    }
    
    body {
      margin: 0;
    }
    
    .navbar {
      overflow: hidden;
      background-color: #333;
      font-family: Arial, Helvetica, sans-serif;
    }
    
    .navbar a {
      float: left;
      font-size: 16px;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
    }
    
    .dropdown {
      float: left;
      overflow: hidden;
    }
    
    .dropdown .dropbtn {
      font-size: 16px;
      border: none;
      outline: none;
      color: white;
      padding: 14px 16px;
      background-color: inherit;
      font: inherit;
      margin: 0;
    }
    
    .navbar a:hover, .dropdown:hover .dropbtn {
      color: #fc7b03;
      background-color: #B5B5B5;
    }
    
    
    .dropdown-content {
      display: none;
      position: absolute;
      background-color: #fc7b03;
      width: 100%;
      left: 0;
      box-shadow: 0px 3px 26px 0px #fc7b03;
      z-index: 1;
      opacity: 95%;
    }
    
    .dropdown-content .header {
      background: red;
      padding: 16px;
      color: white;
    }
    
    .dropdown:hover .dropdown-content {
      display: block;
    }
    
    /* Create three equal columns that floats next to each other */
    .column {
      float: left;
      width: 33.33%;
      padding: 10px;
      background-color: #B5B5B5;
      height: 250px;
     opacity: 100%;
    }
      .column-top {
      float: left;
      width: 33.33%;
      padding: 10px;
     opacity: 100%;
    }
    
    .header2 {
      float: left;
      width: 33.33%;
      padding: 1px;
      background-color: #fc7b03;
      height: 150px;
      opacity: 100%;
      font-size: 12px;
    }
    .header22 {
        float: left;
        position: relative;
      width:33.33%;
      margin-left: 2.5%;
      padding: 1px;
      background-color: #fc7b03;
      opacity: 100%;
      font-size: 12px;
    }
    
    .header2:hover {
      background-color: #B5B5B5;
    }
    
    .column a {
      float: none;
      color: black;
      padding: 16px;
      text-decoration: none;
      display: block;
      text-align: left;
    }
    
    .column a:hover {
      background-color: #ddd;
      color: #fc7b03;
    }
    
    /* Clear floats after the columns */
    .row::after {
      content: "";
      display: table;
      clear: both;
    }
    .row2::after {
      content: "";
      display: table;
      clear: both;
    }
    
    /* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
    @media screen and (max-width: 600px) {
      .column {
        width: 100%;
        height: auto;
      }
      .column-top {
        width: 100%;
        height: auto;
      }
    }
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <div class="navbar">
      <a href="#home">Home</a>
      <a href="#news">News</a>
      <div class="dropdown">
        <button class="dropbtn">Dropdown 
          <i class="fa fa-caret-down"></i>
        </button>
        <div class="dropdown-content">


       

  <div class="row">
            <div class="column-top">
               <img src="https://image.shutterstock.com/image-vector/real-estate-logo-260nw-1615688014.jpg" style="width:50px;  height:50% ">
              <a href="http://google.com">

       
        <span style="display: block" class="header22"> 
        Hello world1
        </span>
    </a>
            </div>
            <div class="column-top">
              <a href="http://google.com">
        <span style="display: block" class="header22"> 
        Hello world2
        </span>
    </a>
            </div>
            <div class="column-top">
               <a href="http://google.com">
        <span style="display: block" class="header22"> 
        Hello world3
        </span>
    </a>
            </div>
          </div>
          
          <div class="row">
            <div class="column">
              <h3>Category 1</h3>
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
            <div class="column">
              <h3>Category 2</h3>
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
            <div class="column">
              <h3>Category 3</h3>
              <a href="#">Link 1</a>
              <a href="#">Link 2</a>
              <a href="#">Link 3</a>
            </div>
          </div>
        </div>
      </div> 
    </div>
    
    <div style="padding:16px">
      <h3>balbllalba</h3>
      <p>Hover over the "Dropdown" link to see the mega menu.</p>
      <p>Re</p>
    </div>
    
    <div style="padding:16px">
      <h3>Responsive Mega Menu (Full-width dropdown in navbar)</h3>
      <p>Hover over the "Dropdown" link to see the mega menu. </p>
    </div>

Related