Shifting H2 Below H1 Using Floats: A Step-by-Step Guide

H2 element won't position below H1.

Currently working on a client's website and facing an issue with the alignment of elements in the navbar. The desired layout includes having an icon on the left, followed by H1 to the right of the icon, and finally H2 beneath H1. I have successfully implemented the first two parts but struggling to make the H2 move under H1. Any suggestions or tips to resolve this problem would be highly appreciated.

    #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: green;
    }
        <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>

Answer №1

Are you satisfied with this?

I decided to enclose the a tag within an h1 tag and then incorporated the clearfix class to manage float clearing.

<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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for Showing an Image on an HTML Page Offline

I am facing a challenge where I need to display an image without relying on an internet connection and without storing the image in cookies. My initial attempt was placing the image URL in the head section using a link tag. <head> <title>@ ...

Issue with SVG on tainted canvas causes IE security error when using toDataURL

In my Angular JS directive, I have implemented a feature to export SVGs to PNG. While this functionality works seamlessly in most browsers, it encounters a security error in IE. Despite my numerous attempts to troubleshoot the issue, I have been unable to ...

I'm having trouble customizing the CSS for the 'table table-bordered' Bootstrap table class. Can anyone offer me some guidance on how to get it to work properly

I'm a beginner in web design and need some assistance. Currently, I am working with Bootstrap 3.0 and have a table with the following data... <table class="table table-bordered" width="100%"> <thead> <tr> <th>Colu ...

Animating the change of background image position in jQuery

Struggling to change the background image position in jQuery animation? Need some assistance to troubleshoot it? Here is the code you are working with: CSS #pnav a{ background:url(http://www.us-bingo.com/images/Tickets/Solid-Color-Tyvek-Wrist-Ticket ...

The communication layer connecting MVC and an HTML page, utilizing AJAX functionality

I have developed a web application and believe that all components are complete. However, I am unsure about how to establish connections within it. The HTML page consists of one field where users can input a word, and my program should parse the top 5 resu ...

Adjust the line spacing in CSS depending on the length of the text

Upon page load, a ul list is dynamically generated via JavaScript. The relevant code snippet is as follows: <ul class="tweet_list"><li class="tweet_first tweet_odd"></li></ul> Related CSS: ​ul.tweet_list li { height: 55px; ...

Troubleshooting a Navigation Tab Problem in Bootstrap 4

Hi, I am new to using bootstrap. Can anyone help me figure out how to achieve the look in the image using bootstrap-04? I want this design to be consistent across all devices, but I am having trouble implementing it. Any guidance is appreciated. Thank you ...

How to determine if an Angular list has finished rendering

I am facing an issue where I have a large array that is being loaded into a ul list using ng-repeat in Angular. The loading of the list takes too long and I want to display a loader while it's loading, but hide it only when the ul list is fully render ...

The flickering on the screen is induced by the Bootstrap multiselect dropdown

I've included the following scripts on my page: 1- MultiSelection.js 2- bootstrap.min.js 3- MultipleSelection.css In my code, I've specified my control like this: <asp:ListBox ID="listBoxProductType" runat="server" SelectionMode="Multipl ...

Finding JPG images using Jquery selector

I am looking to utilize jQuery to specifically target <a href=""> elements that have 'href' attributes with file extensions '.JPG' or '.jpg' For instance: To only select these 'links' <a target=& ...

The HTML Canvas arc function fails to properly align curves

UPDATE Upon further investigation, I've discovered that this problem only occurs in Chrome. Could it be a browser issue rather than a coding problem? I'm working on creating a circle with clickable sections using HTML5 Canvas. The circle itself ...

Is it possible that the mouseover event is only triggered once in jQuery?

Whenever the link is hovered over, I need the submit button to move back so that it doesn't overlap with the comment box that appears when the cursor hovers over it. I tried a solution that worked once, but now I need help making it work every time t ...

Initiating a file download using HTML

When I try to initiate a download by specifying the filename, instead of downloading, it opens in a new tab. The code snippet below shows what I am currently using. Additionally, I am working on Chrome Browser. <!DOCTYPE html> <html> < ...

Waypoint function malfunctioning when overflow:hidden is applied

CodePen If you exclude the overflow property from the CSS selector .wrapper in the CodePen example, the waypoints functionality will work properly. However, it does not function correctly when using the overflow set to hidden either horizontally (x) or ...

Shifting the order of cards along the Z axis

I have been working on my portfolio and have incorporated flipping cards to showcase my android apps. When someone hovers over the cards, they flip and zoom in to display a brief description. The issue I am facing is that the lower cards are overlapping t ...

The footer should never be positioned below the sidebar

Hello, I'm trying to position my footer below my side navigation bar. It's working fine with the header, but I can't seem to figure out how to do it for the footer. Also, another question - how can I ensure that the text on a smaller screen ...

Utilizing CSS only layout to create empty space on the left side of the page

I've been looking but I can't seem to find the right solution to remove the extra white space on the right side. If anyone could assist me in figuring out what needs to be done and explain why, that would be greatly appreciated. Here is a link to ...

Guide on uploading a 3D model in JSON format to Three JS

I am trying to import a JSON file that contains information about a 3D model for Three JS. I have the basic code structure for Three JS and also have a loader function: const loader = new THREE.ObjectLoader(); loader.load( // resource URL "mo ...

What is the process for adjusting the code to manage the labels of specific buttons?

There is a code $("button").click(function() { var btn = this; if (btn.loaded) { $(btn).prev("div").html(btn.originalContent); btn.loaded = false; $(btn).text('Get Dynamic chart'); } else { btn.originalConte ...

Which domain do I need to use: Google or my own, in order to bypass the Access Denied issue in JQuery

I'm currently experiencing a puzzling issue with my website while using Internet Explorer. Despite loading fine in other browsers, I keep encountering a permission denied error within my JQuery code. What's even more perplexing is that this error ...