On the left side of the page, you can find all the navigation bar items

 <header>
    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark navbar-change" id="main_navbar">
        <a class="navbar-brand" href="index.html">
            <img class="logoHeadstart-responsive" src="images/Logo_web_h59px.png" alt="Headstart Malaysia">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse rounded" id="navbarCollapse">
            <ul class="navbar-nav ml-auto" id="menu">
                <li class="nav-item active">
                    <a class="nav-link" href="index.html">Home<span class="sr-only">(current)</span></a>
                </li>
               <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='aboutUs.html'">About</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="aboutUs.html#aboutUs-anchor">Overview</a>
                        <li><a href="#">Facilities</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="aboutUs.html#facilities-anchor">Academy@SACC</a></li>
                                <li><a href="#">Therapy@Damansara</a></li>
                            </ul>
                        </li>
                        <li><a href="#">Team</a>

                        </li>
                    </ul>
                </li>


                <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='#'">Intervention</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="eip.html#overview-anchor" class="eip-text"><span>Early Intervention</span></a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="eip.html#overview-anchor">Overview</a></li>
                                <li><a href="eip.html#admission-anchor">Admission</a></li>
                                <li><a href="eip.html#calendar-anchor">Timetable</a></li>
                                <li><a href="eip.html#academic-calendar-anchor">Calendar</a></li>
                            </ul>
                        </li>
                        <!--<li><a href="#">Junior <span style="background-color: #F18805" class="badge badge-secondary animated pulse">COMING SOON</span></a>-->
                        <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                            <li><a href="#">Overview</a></li>
                            <li><a href="#">Admission</a></li>
                            <li><a href="#">Timetable</a></li>
                            <li><a href="#">Calendar</a></li>
                        </ul>
                        </li>
                        <li><a href="eip.html#devmilestones-anchor">Developmental Milestones</a>

                    </ul>
                </li>

                <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='therapy.html'">Therapy</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="therapy.html">Academy@SACC Mall</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="therapy.html">Behaviour</a></li>
                                <li><a href="therapy.html">Speech</a></li>
                                <li><a href="therapy.html">Occupational</a></li>

                            </ul>
                        </li>
                        <li><a href="therapy.html">Therapy@Damansara</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="therapy.html">Speech</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>


                <li class="nav-item navbar-fixed-top"><div class="dropdown">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='eca.html'">ECA</button>
                    <div class="dropdown-content rounded">
                        <a href="eca.html#eca-anchor">Overview</a>
                        <a href="eca.html#classes-anchor">Classes</a>
                        <a href="eca.html#eca-timetable-anchor">Timetable</a>

                    </div>
                </div>
                </li>             
                </div>
                </li>


            </ul>

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

I am currently working on the design of my company's website and have encountered an issue with the placement of the header. When I paste the code for the header, it appears on the left side of the page instead of at the top as intended.

Previously, I had successfully implemented a similar header in another version of the webpage which included pagination coding. However, when attempting to apply it to this version which includes collapsing posts functionality, the header does not display correctly.

The navigation bar should be horizontal and include dropdown functionality. Unfortunately, it is appearing stuck to the left-hand side of the page rather than at the top where it belongs.

As someone new to web development, I am struggling to troubleshoot this issue and ensure that the header displays correctly. Any guidance or assistance would be greatly appreciated.

Here is how the navigation bar should appear And here is the incorrect appearance

Answer №1

To integrate Bootstrap into your HTML file, you have two main steps:

In the head section of your document:

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

In the body section (ideally towards the end, just before the closing tag):

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

You can see an example here where Bootstrap CDN is utilized through CodePen, without making any changes to your existing code.

<header>
    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark navbar-change" id="main_navbar">
        <a class="navbar-brand" href="index.html">
            <img class="logoHeadstart-responsive" src="images/Logo_web_h59px.png" alt="Headstart Malaysia">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        
        <!-- Navigation links would go here -->
        
    </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

When scrolling, the body content covers up the navbar

Whenever I try to scroll the page, the body contents start overlapping with the navbar. I have content over the navbar that should disappear when scrolling, and it is working correctly. The navbar should be fixed while scrolling, and this functionality ...

Grabbing the HTML value and storing it in a JavaScript variable

In my table, each row has multiple columns including one with a checkbox. When this checkbox is checked, a new column cell appears to the right of the table with an up/down spinner to adjust a value. The issue I'm facing is that I want to limit the s ...

Tips for increasing the size of a parent div when a child div is displayed with a set width?

Is there a way to make the parent div automatically expand when the child div with a fixed width is displayed onclick? Goal: I want the child div to show up when I click the link, and at the same time, I need the parent div to expand or scale to fit the ...

Unauthorized Access with Ajax jQuery

While working on an ajax request using Jquery, I encountered a dilemma. Even though the page is only accessible to logged in users, my cookies are not being sent along with the request. This results in a 401 error. I am already logged in, so why aren' ...

The attempt to remove the ajax-loaded page while preserving the original div is proving to be

I have a function that is triggered when a link is clicked. This function uses ajax to load a new page over a div. <pre><code> function displayContent(id) { loadPage_signup = "register.php"; loadPage_info = "userinfo.php"; $.aj ...

Why do I keep getting an ExpressionChangedAfterItHasBeenChecked error after trying to update a random color in an

Is there a way to assign a random color from an array without causing the error message: "ExpressionChangedAfterItHasBeenChecked"? Even though the color of the chip changes quickly before the message appears, it seems like it's working. How can I reso ...

Using a checkbox to sort through Google Maps markers

I want to create a filter for my google maps markers using checkboxes, inspired by this V3 example. Here's the HTML for the checkboxes: <form action="#"> Attractions: <input type="checkbox" id="attractionbox" onclick="boxclick(this,'a ...

In vanilla Javascript, why does the DOM element update only after the event listener has finished executing?

I'm currently working on a JavaScript program that aims to change the background color of an element after a delay, similar to how a traffic light functions. However, I've encountered an issue. When the button is clicked, the function associated ...

Setting the height and width of a table and utilizing rowspans may not produce the desired outcome

I've encountered an issue with my table that I can't seem to resolve. The CSS should dictate the width and height, but something seems off. Am I approaching this incorrectly or is there something missing? Also, why are the borders not aligning p ...

How can you declare variables in CSS using LESS?

I am facing a challenge where I need to dynamically change the branding color and other styling variables on the portal based on certain conditions at runtime. I have successfully implemented this functionality using CSS with the code snippet provided be ...

Angular Navbar Hover DropDown Expansion

I have been struggling to make my bootstrap 4 navbar in my angular code base expand into a dropdown menu when I hover over the menu items. Despite trying various options all night, I haven't been able to find a solution that works. Below is the HTML, ...

Div tag disrupting the form, causing the list of words to be dynamically added after splitting the text

While experimenting with this code in an asp.net webform, I found myself seeking a way to split a text into individual words in javascript and display each word in its own div. http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_split Unfortunatel ...

Executing a function with the initial click

Is there a way to run a function only on the first click, without having it run every time? I already have another function running on window.onload, so I can't use that. Both functions work fine independently, but not together. Right now, I'm ca ...

"Getting an 'Undefined index' error while trying to pass a variable from jQuery

I am experimenting with passing a variable from an HTML file to a PHP file using jQuery and Ajax for processing. I have created two test files: ajax.html <html> <head> <title>ajax</title> <script type="text/javascript" src= ...

Sorting data with jQuery in ASP.NET

Currently, I am attempting to utilize jQuery sorting on a table in asp.net, but I am encountering some issues. I have tested on the base example and it is not functioning correctly. Below is the code I have implemented: base example <%@ Page Language= ...

Issues with CSS transitions persisting despite switching from jQuery to Vanilla JS

Recently, I made the decision to switch the old code in my <head> from jQuery to Vanilla JS. Essentially, when you click on the hamburger icon, the mobile menu should fade-in and all the links should transition smoothly. I attempted to substitute the ...

Recharge the Div

Looking for a solution to refresh the content within a specific div, I have implemented the following code: <script> $(function() { $("#refresh").click(function() { $("#new").load("/new.php") }) }) </script> The issue I am facing is ...

How can the client be informed about the ongoing processing of the request by the servlet?

In my web application, I have JS/jQuery on the front end and servlets on the back end. When making a request to a servlet, it performs multiple tasks in one call (such as executing a shell script that runs various Python scripts). My main query is whether ...

Enhancing dynamic text boxes with jQuery by incorporating additional information

I've recently developed an interactive app that dynamically creates tables based on user input. The app includes a feature where you can specify the number of tables to generate and track the total count of tables added. Currently, I'm exploring ...

Click the "Login" button using Jquery to gain access

Whenever I hit the Login button, a 500 Internal server error pops up in the console. Can someone guide me on the correct way to perform a POST request using jQuery? I would really appreciate any help. <button class="login100-form-btn" type=& ...