How to Move H2 Beneath H1 With Only Floats

Viewed 260

H2 won't go beneath H1.

I'm building a website for a client, and want to have the navbar with these alignments: Icon on left, H1 to the right of Icon, H2 beneath H1. I have the first two parts done, but my H2 won't move beneath H1. Can anyone help me figure this out?

    #header-nav {
        width: 100%;
        background-color: #3985BA;
        border-radius: 0;
        border: 0;
    }
    
    #logo {
        background: url('../images/piano.png') no-repeat;
        width: 200px;
        height: 200px;
    }
    
    .navbar-brand {
        padding-top: 25px;
        text-align: center;
    }
    .navbar-brand h1 {
        text-transform: uppercase;
        font-family: bebas-neue, sans-serif;
        text-shadow: 1px 1px 1px #222;
        line-height: .75;
    }
    .navbar-brand span {
        text-transform: uppercase;
        color: #A7D8DC;
        margin-top: 15px;
        font-weight: 600;
    }
    .navbar-brand a:hover,.navbar-brand a:focus {
        color: #04292C;
        text-decoration: none;
    }
    
    #header1 {
        color: #04292C;
    }
        <header>
            <nav id='header-nav' class='navbar navbar-default'>
                <div class='container'>  
                    <div class='navbar-header'> 
                        <a href="index.html" class='float-left'>
                            <div class='d-none d-sm-none d-md-none d-lg-block d-xl-block' id='logo' alt='piano logo'></div>
                         </a>
                    <div class='navbar-brand'>
                        <a href='index.html' class='float-left' id='header1'><h1>Sandra's Studio</h1></a>
                         <p>
                             <span id='header2'>Cumming, GA</span>
                         </p>
                     </div>
    
                 </div>
             </div>
         </nav>
     </header>

1 Answers

Is this what you want?

I wrapped the a tag with h1, then added clearfix class to clear the floats.

<h1 class="clearfix">
   <a href='index.html' class='float-left' id='header1'> 
   Sandra's Studio </a>
</h1>

#header-nav {
  width: 100%;
  background-color: #3985BA;
  border-radius: 0;
  border: 0;
}

#logo {
  background: url('../images/piano.png') no-repeat;
  width: 200px;
  height: 200px;
}

.navbar-brand {
  padding-top: 25px;
  text-align: center;
}

.navbar-brand h1 {
  text-transform: uppercase;
  font-family: bebas-neue, sans-serif;
  text-shadow: 1px 1px 1px #222;
  line-height: .75;
}

.navbar-brand span {
  text-transform: uppercase;
  color: #A7D8DC;
  margin-top: 15px;
  font-weight: 600;
}

.navbar-brand a:hover,
.navbar-brand a:focus {
  color: #04292C;
  text-decoration: none;
}

#header1 {
  color: #04292C;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<header>
  <nav id='header-nav' class='navbar navbar-default'>
    <div class='container'>
      <div class='navbar-header'>
        <a href="index.html" class='float-left'>
          <div class='d-none d-sm-none d-md-none d-lg-block d-xl-block' id='logo' alt='piano logo'></div>
        </a>
        <div class='navbar-brand '>
          <h1 class="clearfix"><a href='index.html' class='float-left' id='header1'> Sandra's Studio </a></h1>
          <p class="text-left">
            <span id='header2'>Cumming, GA</span>
          </p>
        </div>

      </div>
    </div>
  </nav>
</header>

Related