Creating a navigation bar with a logo: A step-by-step guide

I'm trying to create a subnav below my navbar with the text aligned to the right and the logo positioned on the left. However, I'm facing issues with moving the text to the right and adjusting the position of the logo. How can I move the logo down slightly to create some space between it and the line? Thank you for your help!

https://i.sstatic.net/EZBQh.png

body {
    margin:0;
    padding: 0;
    font-family: "Open+Sans", sans-serif;
 }

 .navbar {
    border-bottom: 2px solid #0C133C;
 }
 
 
 #nav {
     background-color: #fff; 
     color: white;
     width: 100%;
 
 }
 .nav {
   float: right;
     text-align: left;
   margin: 0;
 }
 .nav > li {                                                             
     display:Inline-block;
     padding: 20px 50px 10px 9px;                              
 }
 
.nav > li a {                                               
    text-decoration: none;
    color: #0C133C;
    font-size: 18px;
    border-bottom: 3px solid transparent;
}
.clearer {
    clear:both;
}

  
}
.subnav class{
  margin: 0;
position:relative;
}

 .subnav > div a {                                               
     text-decoration: none;
     color: #0C133C;
     font-size: 18px;
padding: 20px 30px 10px 9px;
}
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Navbar</title>
    <link rel="stylesheet" href="styles.css"
    

</head>

<body>

<div class="navbar">
            <ul class="nav">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="#">Get a Quote</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="#">Contact Us</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="#">Sign In</a>
                </li>
            </ul>
            <div class="clearer"></div>
        </div>
        

<subnav class="subnav subnav-light bg-light">
<div class="container-fluid">
<a class="subnav=brand" href="#">
<img src="universallogo.jpg"
 <a class="nav-link active" aria-current="page" href="#">Bonds</a>
</a>
 <a class="nav-link active" aria-current="page" href="#">Report a Claim</a>
 <a class="nav-link active" aria-current="page" href="#">About Us</a>
</div>
</subnav>
 
</ul>




</body>
</html>

Answer №1

Experiment with these styles by using flex on the parent element and applying justify-content: space-between; to align elements on the right and left sides. To differentiate your logo, assign it a class and add some margin to create distance from the bottom border of the nav. I have substituted your logo with a placeholder image for illustrative purposes.

body {
    margin:0;
    padding: 0;
    font-family: "Open+Sans", sans-serif;
 }

 .navbar {
    border-bottom: 2px solid #0C133C;
 }
 
 
 #nav {
     background-color: #fff; 
     color: white;
     width: 100%;
 
 }
 .nav {
   float: right;
     text-align: left;
   margin: 0;
 }
 .nav > li {                                                             
     display:Inline-block;
     padding: 20px 50px 10px 9px;                              
 }
 
.nav > li a {                                               
    text-decoration: none;
    color: #0C133C;
    font-size: 18px;
    border-bottom: 3px solid transparent;
}
.clearer {
    clear:both;
}

  
}
.subnav class{
  margin: 0;
position:relative;
}

 .subnav > div a {                                               
     text-decoration: none;
     color: #0C133C;
     font-size: 18px;
padding: 20px 30px 10px 9px;
}

.logo {
  margin-top: .5rem;
}
.subnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-right: 1rem;
}
<!doctype html>
<html>
   <head>
      <meta charset="UTF-8">
      <title>Navbar</title>
      <link rel="stylesheet" href="styles.css"
   </head>
   <body>
      <div class="navbar">
         <ul class="nav">
            <li class="nav-item">
               <a class="nav-link active" aria-current="page" href="#">Get a Quote</a>
            </li>
            <li class="nav-item">
               <a class="nav-link active" aria-current="page" href="#">Contact Us</a>
            </li>
            <li class="nav-item">
               <a class="nav-link active" aria-current="page" href="#">Sign In</a>
            </li>
         </ul>
         <div class="clearer"></div>
      </div>
      <subnav class="subnav subnav-light bg-light">
      <img src="https://dummyimage.com/200x100/000/fff" class="logo"/>
         <div class="container-fluid">
            <a class="subnav=brand" href="#"></a>
            <a class="nav-link active" aria-current="page" href="#">Bonds</a>
            
            <a class="nav-link active" aria-current="page" href="#">Report a Claim</a>
            <a class="nav-link active" aria-current="page" href="#">About Us</a>
         </div>
      </subnav>
   </body>
</html>

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

Is it possible to include Helvetica or a similar font in my web application for shipping?

My web-app is Java/HTML based and hosted on the cloud. Users will access it using IE, Chrome or Mozilla. I would like to use Helvetica or a similar font, but they are not readily available on most systems (windows/IE/Chrome/Mozilla). Is there a way for me ...

Nested Bootstrap structure with a column containing two sub-columns

I am attempting to create a grid layout using bootstrap. The layout should consist of a full 12 column layout on desktop, with an 8 column grid and a 4 column grid within it. The 8 column grid will contain an image/text, while the 4 column grid will have t ...

Changing Ionic Column Widths Based on Content Length

In my dynamic ionic 2 grid system, I am facing a layout issue. <div> <ion-row> <ion-col > ; <ion-card-header class="card-header"> {{hunt.title}} </ion-card-header> </ion-col> <ion-col *ngIf="!hunt. ...

Extract content within Python pre tags

A Python code snippet is being used to extract content between PRE tags: s = br.open(base_url+str(string)) u = br.geturl() seq = br.open(u) blat = BeautifulSoup(seq) for res in blat.find('pre').findChildren(): seq = res.string ...

The tag's onclick function that was dynamically created was not triggering in jQuery

I created a web application using jquery mobile and ran into an issue. I am trying to call a function by clicking on a dynamically generated anchor tag, but it's not working and showing an error that the function is not defined. Any assistance on this ...

Display or conceal columns based on their index

<div ng-controller="checkBoxController"> <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="moda ...

What is the best way to center two items within a border?

Here is the CSS code I wrote to center align my text with a bottom border: .arrow-down { width: 2rem; display: inline; position: absolute; top: -0.6rem; left: 50%; margin-left: -59px; background: $grey_200; z-index: 5; } .showless > se ...

Keep an ear out for upcoming occasions once the transition has been completed

I am looking to create a smooth transition effect that will push the main content downwards when the Twitter Bootstrap collapse menu is activated using the toggle button. However, I have noticed an issue where if I quickly double click the toggle button, ...

Experiencing difficulties while transferring a json encoded array from php to a js file due to an error message saying "Unexpected end of input."

I am attempting to pass an object array to a JavaScript function every time a button is clicked. <button onclick="actualizarProcesos(<?php echo json_encode($p_array)?>);">X</button> I have ensured that my JSON data does not contain any ...

Utilizing HTML5 to Access and Update custom data attributes

I have implemented the following code: var activeFilter = $('<li></li>').data('input-id', 'mycustomId'); $('#container').append(activeFilter); Now, I am faced with the challenge of retrieving a specific ...

triangular shape at the top and rounded shape at the bottom combined with various colors

Is there a way to create a triangle with a rounded bottom section in a different color? #box { content:""; width: 0; height: 0; border-style: solid; border-width: 0 150px 150px 150px; border-color: transparent yellow red blue; ...

CSS shrink effect upon hovering

I'm currently working on designing a menu using <ul>/<li> tags along with CSS styles. Here's the progress I've made so far with my menu design: https://jsfiddle.net/gANfS/6/ However, I encountered an issue where if you hover ov ...

The issue of not being able to type in the sweetalert 2 input within a material UI modal in a

Within a card displaying an order, there is a sweetalert2 popup that opens when trying to cancel the order, asking for a cancellation reason. This feature works seamlessly on the orders screen. https://i.sstatic.net/RWhOA.png <Grid item md={8} sm={12}&g ...

Is there a way to create a div that resembles a box similar to the one shown in the

Hello, I am attempting to achieve a specific effect on my webpage. When the page loads, I would like a popup to appear at the center of the screen. To accomplish this, I have created a div element and initially set its display property to 'none'. ...

What is the reason for the index.html file not connecting to the local .css files and .js file?

I'm currently using node.js to send an .html file that includes the following tags: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="This is my personal profile website" /> <link r ...

Utilizing jQuery to close a modal when clicking outside of its container

Trying to target elements in my practice layout but struggling to figure out the right approach: BASIC HTML <button id="opencontact" type="button" name="button"> <i class="far fa-envelope fa-2x"></i> </button> <section id="c ...

Using Vue to alter data through mutations

Greetings! I am currently in the process of developing a website for storing recipes, but as this is my first project, I am facing a challenge with modifying user input data. My goal is to create a system where each new recipe added by a user generates a u ...

PHP - Variables can only contain text characters

I am in the process of creating a website and I require a specific function. This function is intended to convert the string into plain text only. For example: $string = "Hello world<div width="100000">aaa</div>"; Rendering this as HTML cou ...

Tips for managing the creation of dynamic Bootstrap cards using jQuery

I am embarking on the creation of an entertaining game where users can input their name and email address. Upon clicking the "Add" button, a new card will be generated containing a form with checkboxes labeled "One" and "Two". Depending on the selection of ...

Assistance with Squarespace code injection: Enhancing hover effects on the Flat-Iron template

While browsing the index gallery, I noticed that the Flat-iron template has an opacity change when you hover over images. I'm curious if it's possible to reverse this effect so that the images remain at a low opacity until hovered over to reveal ...