What could be the reason for this tag not functioning properly?

I am facing an issue with my navbar where the <a> tag is not updating the URL to the new address. I have tried giving the <a> tag a z-index 999;, but it still doesn't work.

This is a one-page site and I use # to make the browser jump to the correct position.

I do not have a .htaccess file, the code provided is all that I have.

HTML

<nav class="navbar col-md-12">
    <div class="container">
        <div class="logo">
            <div class="fa-microphone"></div><label>Bit-meeting</label>
        </div>

        <ul class="hidden-xs desktop-menu">
            <li>
                <a href="#Forside">Forside</a>
            </li>

            <li>
                <a href="#Om">Om</a>
            </li>

            <li>
                <a href="#Plan">Plan</a>
            </li>

            <li>
                <a href="#Talere">Talere</a>
            </li>

            <li>
                <a href="#Billetter">Billetter</a>
            </li>

            <li>
                <a href="#Blog">blog</a>
            </li>

            <li>
                <a class="btn btn-border" href="#Kontakt">Kontakt</a>
            </li>
        </ul>
    </div>
</nav>

SCSS

.navbar {
    height: $navbar;
    width: 100%;
    position: fixed;
    border-bottom: 2px solid $red;
    z-index: 19;
    background-color: white;

    margin: 0px;
    padding: 0px 15px;

    .logo {
        margin-left: 15px;
        display: flex;
        line-height: $navbar;
        text-indent: 5px;
        font-size: 1.2rem;
        font-weight: bold;
        text-transform: capitalize;
        position: absolute;
        div {
            text-indent: 0px;
            color: black;
            font-family: FontAwesome;
            background-color: #ED1C24;
            width: 60px;
            height: 60px;
            font-size: 2rem;
            text-align: center;
            line-height: 60px;
            border-radius: 50%;
            margin-top: 10px;
        }
    }

    .desktop-menu {
        float: right;

        li {
            list-style-type: none;
            display: inline-flex;

            a {
                padding: 0px 10px;
                line-height: $navbar;
                text-decoration: none;
                color: black;
                height: $navbar;
                cursor: pointer;
                display: block;

                &:hover {
                    background-color: $red;
                    color: white;
                }
            }

            .btn {
                line-height: 38px;
                height: 40px;
            }

        }
    }
}

UPDATE

The <a> tag does not work at all, even outside of the nav element. (No, there are no additional styles for ul, li or a beyond what is visible)

Answer №1

To modify the displayed URL using anchors, JavaScript is required.

For instance:

JavaScript:

function updateURL(key){
    history.replaceState({}, "", key);
}

Your Link:

<a href="#Home" onClick="updateURL(this.href)">Home</a>

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

Using Jquery and CSS to add a class with a 1-second delay when the mouse enters

I have successfully implemented the addClass function in my code, but I'm encountering issues when attempting to use delay or setTimeout functions. It's important to note that I'm avoiding the use of webkit attributes in CSS. If anyone has ...

Counting checkboxes in jQuery version 1.9

I recently upgraded my website from jQuery 1.6 to jQuery 1.9.1, and now some of my old code is not working as expected. Specifically, I have a piece of code that handles checkboxes in table rows, allowing only up to 5 checkboxes to be active at once and di ...

SWI-Prolog and the Selection drop-down element in HTML

Is there a way to convert this code into SWI-Prolog? I couldn't find any information online on how to write the select statement in Prolog. Can you also provide guidance on making the PHP code function properly within the context of SWI-Prolog? <s ...

Creating a hierarchical JSON structure to populate a Handlebars template (HTML) for an iterative component, allowing for the display of three levels of interconnected

Currently, I am working on developing a mega menu component that involves three levels of content. Level 1 (L1): This level is displayed horizontally in a traditional navbar. When hovered over, it expands to reveal the mega menu. Level 2 (L2): These item ...

Error: Compilation was unsuccessful due to module not found. Unable to resolve in ReactJS

As I was wrapping up this task, an unexpected error popped up: Module not found: Can't resolve './components/Post' in ./src/pages/index.js I've tried everything to troubleshoot it but no luck. Here's a rundown of my code snippets ...

Error: The column 'joinedactivities.searchact id = searchact.id' is not recognized in the 'on clause'

I keep encountering this particular error: Error: Unknown column 'joinedactivities.searchact id = searchact.id' in the 'on clause'. I have meticulously inspected the table names and even attempted to make modifications, but multiple err ...

Automating the process of posting a file to a form with javascript

I have a piece of client-side JavaScript that creates a jpeg file through HTML5 canvas manipulation when the user clicks an "OK" button. My goal is to automatically insert this jpeg output into the "Upload Front Side" field in a form, simulating a user up ...

A fixed header for tables that shifts along with horizontal scrolling

Seeking assistance with a persistent issue - I have a table with a fixed header on vertical scroll (see CSS and Javascript below), but the header fails to move horizontally when I scroll. window.onscroll = functi ...

Tips for efficiently webscraping multiple pages with Beautiful Soup

I have been running my web-scraping script for quite some time, but it seems to be stuck on scraping only one URL. I intend to scrape five different URLs, and I am wondering if the issue lies with my loop getting stuck in an infinite loop. Furthermore, I ...

How can I adjust the brightness, contrast, saturation, and hue in HTML5?

Is there a way to adjust the brightness without turning the image grey? I've been attempting to do so, but only managed to change it to greyscale. My objective is to increase and decrease the brightness of the image. Here is the current code: HTML ...

What is the best way to adjust the z-index of a dropdown auto complete to appear above a background image?

Is there a way to adjust the z-index of the drop-down autocomplete box so that it appears above a background image? Take a look at this screenshot: The four images below are background images styled with sprite CSS. The area box represents the drop-down ...

Connecting mysql workbench data using html: A step-by-step guide

I'm currently creating a user interface for a database system using HTML. I'm a bit stuck on how to access and manipulate the database in MySQL Workbench. Does anyone have any suggestions or sample code that could help me connect them? Thanks! ...

Adjustments to make for custom span and gutter width in Bootstrap's values

Looking to design a fixed layout with Bootstrap? Want to set span3 to 278px and gutter width to 12px for a total width of around 1142px? I tried the Customize tool on the Bootstrap site, but didn't get the desired result. Any advice on the correct val ...

Error Encountered While Submitting Email Form

I'm having trouble with my email submission form on my website. I've checked the code and it seems fine, but for some reason, the submissions are not going through successfully. Even when bypassing the JavaScript and directly using the PHP script ...

Building a table using a JSON object in a React component

I have been dynamically creating a table in React based on the API response received. data = {"name":"tom", "age":23, "group":null, "phone":xxx} Everything was working fine until I encountered a scenario w ...

"Trouble with Express.js: CSS isn't loading, yet HTML displays

Click here to view folders and files server.js is the code I have created so far //importing packages const express = require('express'); const admin = require('firebase-admin'); const bcrypt = require('bcrypt'); const path = ...

The system considers the resource as a script, yet it was transmitted with the MIME type of text

I am encountering an issue when trying to integrate AngularJS/JavaScript into my HTML document. Each time I try to load my index.html file, the following error message appears: Resource interpreted as Script but transferred with MIME type text/html: "http ...

What is the best way to retrieve the targeted style directly from CSS, rather than relying on the computed style of the element?

Although similar questions have been posed before, such as this one, I haven't found a working solution. Is there a way for me to retrieve the width attribute value from a CSS class and then write it to a div? I'm looking to access the exact va ...

What methods can be utilized to ensure that my wistia video player/playlist is responsive on different devices

I need some assistance with making my Wistia player responsive while using a playlist. I want the video player to adjust its size based on the screen size. Here is an example: My current code utilizes their iframe implementation: <div id="wistia_1n649 ...

When the web browser page is zoomed out (Ctrl -), elements do not appear to float

Can you test resizing the window to the minimum (CTRL-)? Here's the link: http://jsfiddle.net/Zty9k/13/ This is the HTML code: <ul> <li><img src="http://i.imgur.com/PBuDAFH.gif"></li> <li><img src="http://i.i ...