How can I position the navigation bar ul list on the opposite side of the logo?

I've been struggling to align the text within my id= "nav-bar" to the right of the header using float:right. Despite attempting options such as using float:left and absolute positioning for the logo on the left, I haven't been successful. Even after trying clearfix for the id=nav-bar, the issue persists. Does anyone have any suggestions on how I could resolve this problem? Your help would be greatly appreciated! Please refer to the code below.

<style>
    html,body{
      font-family: 'Open Sans',sans-serif;
      text-align: center;
    }

    *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      
    }

    #page-wrapper {
      position: relative;
    }

    #header {
    position: fixed;
    top: 0;
    left: 0;
    height: 125px;
    }

       .logo {
    float: left;
    }

  #header-img {
    height:100%;
  }

    nav {
      position: relative;
      float: right;
     height: 10vh;
     color:blue;
      }

    li {
      display: inline-block;
      list-style: none;
     
    }

    a {
      color: #000;
      text-decoration: none;
    }





</style>
<!DOCTYPE type>
<html>
  <head>
    <meta charset="utf-8"> 
  </head>
  <body>
    <div id="page-wrapper">
     <header id="header">
      <div class="logo">
       <img id="header-img" src="http://image.discountsoff.com/dryKPIu3fpLUjodbv1n2Q2EWdkA=/logos/aersf.com.png">
        </div>

          <nav id="nav-bar">
            <ul>
              <li><a class="nav-link" href="#features">Features</a></li>
              <li><a class="nav-link" href="#products">Products</a></li>
              <li><a class="nav-link" href="#about us">About Us</a></li>
            </ul>
          </nav>
     </header>



        <div class="container">
          <section id="features">
            <div class="grid"></div>
              <img class="lock feature" src="file:///F:/Coding/Product%20Landing%20Page/lock%20feature.svg" alt ="features"></img>
              <div class="description"><h2>Lock Feature<h2><p>Aer started in 2014 as a crowdfunding project that combined a gym bag and an office bag into one simplified design. That project has grown into a mission to simplify the way you carry so you can worry less about what's on your back and focus more on what's ahead. Whether you're traveling between the office and the gym, or from San Francisco to Tokyo, there's a bag in our collection that's perfectly suited for your journey.</p></div>


             <div class="icon-bag"></div>
              <img class="zip feature" src="file:///F:/Coding/Product%20Landing%20Page/zip%20feature.svg" alt="full bag"></img>
              <div class="description"><h2>Zip Feature</h2><p>The Active Collection is a line of modern gym/work bags designed for the city professional. Go from the office to the gym and everywhere in between.</p></div>


              <div class="grid"></div>
                <img class="lap top feature" src="file:///F:/Coding/Product%20Landing%20Page/lap%20top%20feature.svg" alt="about us"></img>
                <div class="description"><h2>Lap Top Feature</h2><p>Inspired by the city, we create minimalist bags that balance smart features with a clean, architectural style.</p></div>
          </section>      
        </div>



          




        <div class="container">
          <section id="products"></section>
          <iframe width="560" height="315" src="https://www.youtube.com/embed/qeFOYlHmyGE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
        </div>



        <div class="container">
          <section id="about us"></section>
        </div>

    </div>    
  </body>
</html>

Answer №1

Without a specified width for your header, it is simply taking up the space required by its content and not expanding to cover the entire width of the page. To remedy this, you should set a specific width for your header.

To achieve this, include width: 100% in the styling for your #header element.

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

Displaying data in an HTML table using PHP and adding a popup

I've successfully created a PHP script that retrieves data from a MySQL database and organizes the results into an HTML table. Within one of the fields in the database, there are links to file(s), separated by commas. Everything is working well thanks ...

Designing a fresh look for the developer portal on Azure API Management Services

Is there a way to customize the color of the navbar links in the fresh developer portal for different layouts? I have attempted using the designer tool provided by the portal, but it hasn't yielded any results. I also tried cloning the git repository ...

Tips for integrating v-virtual-scroll with v-table?

My Vuetify table is handling a large amount of data – 300 rows with 20 columns, some of which have calculated rowspans. To improve performance, I'm considering using the v-virtual-scroll component. I came across this sample code, which doesn't ...

Hover function not functioning properly

I can't figure out why this hover effect isn't working, there doesn't seem to be a negative z-index or anything like that. At most, it just flashes on hover; .menu{ border-radius: 50%; width: 100px; height: 100px; background: white; box-sha ...

Check out this unexpected margin issue affecting the first element within the Container! Can you please provide an explanation for this anomaly?

Take a moment to check out this fiddle. In Container1 and Container2, the background color is set to #ccc, and h1 and .logo div have margins. While the left and right margins are working properly, the top and bottom margins are not functioning as expected. ...

Hide a header and bring it back after a 2-second delay

I REPLIED BELOW Is there a way to make the header of my webpage fade out when scrolled and then be hidden using style.display? Here's what I have so far: <script type="text/javascript> function Scroll() { var head = document.getEl ...

The percentage height setting for a div is not functioning properly, but setting the height in pixels or viewport

Within a dialog box body, I am attempting to display a table and have applied a CSS class to the wrapping div. When specifying the height in pixels or viewport height units, it works as expected. However, when using a percentage like 50%, the height of the ...

"Header background image gradually fades out and disappears as you scroll, revealing a bottom gradient effect in a React application

When I scroll, my header image fades away. I used JavaScript in my React app to achieve this effect: useEffect(() => { const handleScroll = () => { if (parallaxDiv.current) { parallaxDiv.current.style.backgroundPositionY = `${ ...

If an input type="file" is empty, then $this->form_validation->run() will return false

Whenever I make changes to my settings and leave the input type="file" empty, $this->form_validation->run() consistently returns false. Surprisingly, I haven't utilized setrules or required it. Below is the snippet of my code: public function ...

What is the best way to retrieve values from li elements using Cheerio/jQuery?

<div class="tabs__content tabs__content--bg js-tab-panel"> <div class="tabs__panel tabs__panel--active"> <div class="product__sizes-wrapper"> <ul class="product__sizes-select js-size-select-l ...

Internet Explorer 8 is throwing an error with code SCRIPT438, indicating that the object does not have the capability to support the property or method known

Encountering an error in IE8 when loading the jspdf.debug.js file: SCRIPT438: Object doesn't support property or method 'getContext' and SCRIPT257: Could not complete the operation due to error 80020101. After researching with Google, un ...

Copying text from an iframe using HTML and JavaScript

As someone who is relatively new to web development, I am currently attempting to transfer text from an iframe to a textarea located on a Bootstrap-html webpage. You can view an example of the code I am working with here: https://jsfiddle.net/fe5ahoyw/ J ...

Is there a way to conceal the horizontal divider in the login form of the ionic HTML mobile user interface?

While designing this login form on the HTML ionic mobile UI, everything looks good except for one thing - I want to hide the horizontal line that appears between the "Forgot Password" label and the LOGIN button. Is there a way to do this? Login.html: < ...

What is the best way to style the header of a table when scrolling in CSS?

Currently, I am facing an issue with applying the top CSS property to the thead element of a table while scrolling. I have attempted various methods but have been unsuccessful in achieving the desired outcome. Initially, I used the scroll event, however, ...

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

Tips for Adjusting the Position of a DIV Element Slightly Upwards

I am having trouble positioning the home-link image in my hovering navigation bar. The URL to my blog is: . Ideally, I want the image to be aligned with the text tabs next to it, but no matter what I try, I can't seem to move the "home" icon up by abo ...

Is window.getComputedStyle not functioning as anticipated?

Here is a function I created to determine the width and height of a text: function size_calculation(word,fontSize) { const div = document.body.appendChild(document.createElement('div')); div.textContent = word; div.style.cssText = ` fo ...

Position the end of a div to the left side of the container with this technique

I have encountered an issue while trying to showcase a floating bubble with a message located on the left side of the bubble. Despite using absolute positioning and setting a fixed value for the left property, whenever the message text changes, the width o ...

What is the best way to align a div block with images horizontally?

Trying to center a block of images horizontally, but struggling to get the alignment right. The HTML code looks like this: <div id="dealerarea"> <div id="dealercards"> <!--Images by Javascript--> </div> </div> He ...

Adjustable width columns in Flexbox design

I need assistance with creating a responsive three-column grid layout using Flex in CSS. I have achieved a fairly responsive design by following the CSS provided in the fiddle link below. However, I am facing an issue where the second column (the blue one) ...