Simple CSS positioning questions - where could I be going astray?

Hi there! I'm a newbie to the world of CSS/HTML and struggling to figure out what's going wrong.

I'd like the three navigation links on the right side to appear at the top of the page, but currently they are showing up below the navigation links on the left side.

All of them are nested within div.wrapper, yet it seems like nav#menu2 is not properly included?

Where could I be making a mistake?

Check out the HTML code below:

<header>
    <div class="wrapper">
        <h5 class="logo">TESTER SITE</h5>
        <nav id="nav_menu">
            <ul>
                <li><a href="#">About Us</a>
                    <ul>
                        <li><a href="#">Mission & Background</a></li>
                        <li><a href="#">Objects, Vision & Values</a></li>
                        <li><a href="#">Staff Members</a></li>
                        <li><a href="#">Board Members</a></li>

                    </ul>

                </li>


                <li><a href="#">Our Projects</a></li>
                <li><a href="#">Training & Events</a></li>
                <li><a href="#">News</a></li>
                <li><a href="#">Publications</a></li>

            </ul>
        </nav>

        <nav id ="menu2">
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">Service Providers</a></li>
                <li><a href="#">Contact</a></li>
                <li><a href="#">FB</a></li>
                <li><a href="#">TW</a></li>

            </ul>


        </nav>

    </div>
</header><!--  End Header  -->

And here is the CSS snippet:

body {
padding:0;
margin:0;
vertical-align:baseline;

}

/* More CSS code... */

Visit this link for the complete code.

Answer №1

To give your menus some float positioning, consider adding float:left;.

You should also adjust the percentage values for header nav#nav_menu and nav#menu2, as they currently add up to 105%.

Here's how you can modify your code:

header nav#nav_menu,
header nav#menu2 {
  float:left;
}

header nav#nav_menu {
  width:45%;
}

Check out this example for reference.

On a side note, it's recommended to use a CSS Reset in the future to avoid default padding on elements like lists in your header.

Answer №2

It appears that a precise adjustment of widths and the utilization of floats are needed in this case. Take a look at this demonstration

I made adjustments to the floats:

#nav_menu, #menu2{float:left;}

Additionally, I decreased the width of the initial menu from 65% to 35%.

Hope this helps, -Ted

Answer №3

View your custom stylesheet here:

header nav#nav_menu{

width:65%;
position:;

}

The property position is missing a value. You can go ahead and remove it.

Next, manually update the styling for #menu2 like so:

header nav#menu2 {
float:right;
width:40%;
margin-top:-17px;

}

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 implementing a CSS Flexbox layout with varying div heights

I am working on a page that features five unique panels, each with its own distinct height and width. I have been considering implementing CSS Flexbox to ensure these panels stack properly as the page becomes responsive. However, one major issue I've ...

Halt the execution of a function upon clicking a div element

I'm currently working on a function that needs to be stopped when a div with the class "ego" is clicked. This function toggles the visibility of the header based on the scroll position and should only run by default. Below is the code snippet: $("#e ...

What is the best way to implement rotation functionality for mobile devices when dragging on a 3D globe using D3.js and an HTML canvas?

I have been experimenting with the techniques demonstrated in Learning D3.js 5 mapping to create a 3D globe and incorporate zoom and rotation functionalities for map navigation. Here is the function that handles both zooming and dragging on devices equipp ...

When the down key is pressed in a textarea, choose the list item

I have HTML similar to the following <div class="row"> <textarea id="txtArea" ng-model="input" ng-change="handleOnChange(input);getSearchField(input);" ng-click="search(input)" ng-focus="search(input);" ...

Upon hovering, icons for each project name are displayed when `mouseenter` event is triggered

My issue lies with the mouseenter function. I am trying to display icons specific to the project name I hover over, but currently, it displays icons for all projects at once. I want each project hovered over to show me its respective icons Below is some c ...

What are the steps to recreate the layout of my image using HTML?

What's the best way to create a layout in HTML that expands to fit the entire screen? ...

Incorporating a class into ever-changing Bootstrap Table rows

Looking to enhance my table rows with a class, excluding the header. Struggling to find a way to do this. Any ideas? This is the table in question: <table id="table" class="hidden table table-bordered table-striped table-hover"> <thead> ...

Why is the angular navigation bar not appearing on the screen?

Currently, I am in the process of learning Angular through a Udemy course instructed by Maximilian Schwarzmuller. One of the topics he covers is creating a navigation bar. I have tried to implement the same code for my navigation bar, but unfortunately, it ...

Utilize jQuery to create a dynamic image swapping and div showing/hiding feature

I'm having trouble implementing a toggle functionality for an image and another div simultaneously. Currently, when the image is clicked, it switches to display the other div, but clicking again does not switch it back. Can someone please advise on wh ...

Unable to locate module in Vue.js when using browserify

When trying to use almost every npm package with vue.js 1.0, I keep encountering this frustrating error: { Error: Cannot find module '!!./../../../node_modules/css-loader/index.js!./../../../node_modules/vue-loader/lib/style-rewriter.js!./../../../no ...

Providing access to information even in the absence of JavaScript functionality

Is it possible to make the content of a webpage using jQuery/JavaScript visible even when JavaScript is disabled? Currently, I have a setup where clicking on an h2 header will display information from div tags using the jQuery function. I've made sur ...

What is the best way to implement a 'box-shadow-right' that stops at the border?

How can I achieve a seamless shadow effect at the border-right of a small div that matches the shadow of a larger div, without cutting off at the border-bottom of the small div or the border-top of the large div? I am unable to use Z-index due to the compl ...

The issue at hand is that one of the JavaScript buttons is functioning properly, while the other is not playing the video as intended. What steps can

I've been working on a script for my school project website that should make buttons play videos, but I'm running into an issue where it only works for the first button (btn). Programming isn't my strong suit, and I put this together based o ...

How do I switch back and forth between displaying content as 'none' and 'block' using JQUERY?

Take a look at this code snippet. <div class="sweet-overlay" tabindex="-1" style="opacity: 1;display: none;"></div> Is there a way to switch the style attribute value from none to block and back? ...

The conditional statement within an AngularJS object is reliant on the selected option within an HTML dropdown menu

I am looking to apply an if condition in an object to capture specific values from two HTML select options. The Angular framework will then post these values to the database based on the user's selection. HTML <tr> <td>En ...

Is it possible to determine if a web page is designed for a personal computer or a

Is there a way to identify whether a given URL is intended for PC or mobile devices? I have a collection of URLs, and I need to determine if each one corresponds to a PC or mobile version. Is there any specific HTML element or marker within the page sour ...

The enchanting world of CSS background scrolling animations

I am currently developing a website where I have split the hero/header into two sections - one on the left with information and the other on the right with a graphic. I wanted to add a simple parallax effect to the image on the right side, so I used backgr ...

The property value for -webkit-overflow-scrolling: touch is not valid

Can someone help me figure out why this code isn't working? I included it in both my html and body elements, but I keep getting an error message saying "invalid property value" and it's crossed out. Initially, I tried using it within my media que ...

To add a code snippet to the right side of a paragraph using CSS, place it at the end of the

Is there a way to insert code at the end of each paragraph and have it aligned to the right on the same line as the last sentence? Update: I initially tried using float:right, but encountered an issue with vertically aligning the code with the last line ...

React - CSS Transition resembling a flip of a book page

As I delve into more advanced topics in my journey of learning React and Front Web Dev, I discovered the ReactCSSTransitionGroup but learned that it is no longer maintained so we now use CSSTransitionGroup. I decided to create a small side project to expe ...