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

dividing Handlebars HTML content into different files or sections

I am looking to design a single route webpage, but I would like to divide the HTML code into multiple files. When rendering this particular route, my goal is for the rendered file to pull content from different template files and combine them into one coh ...

Using Rails to load an image from CSS

My current approach to loading an image is using this code: <div id="bglion"><%= image_tag("BG-LION6.png")%></div>, which successfully displays the image. However, I am interested in loading the image from a CSS file instead. After resea ...

Tips for fixing alignment problems using CSS

I am experiencing a problem where I am unable to figure out how to align the content in one column with text positioned next to it in a right-aligned format. /* Personal Details */ .personal-info { width: 90%; padding: 25px; border-bottom: 1px so ...

"Exploring the Power of Angular with HTML Checkboxes

I am trying to display a checkbox as either checked or unchecked based on the value of a variable {{CurrentItem.STATUS}}, which can be either 1 or 0. Is there an Angular solution that does not require any javascript/typescript to achieve this? I want the ...

Is it possible to align a CSS table row with its corresponding table header even when the table row is deeply nested within the table structure?

I am looking to keep the structure of my HTML code consistent and unaltered. However, this has resulted in a form tag being nested inside a table row before the table cells can begin. The information I need to display is tabulated data, which makes CSS t ...

To replace basic SVG icons upon clicking with the use of HTML, CSS, and jQuery - here's how!

I have a simple question about inline SVG icons and how to handle them in HTML, CSS, and jQuery. Despite reading numerous resources, I still struggle with implementing the functionality where clicking on one icon changes it to another. My objective: To to ...

Utilize CSS to create a column layout

I have some HTML output that I would like to style using CSS, but unfortunately I have no control over how the HTML is generated and cannot make any changes to it. Right now, I have a two-column layout set up here: http://jsfiddle.net/uvg6f3tr/ I'm ...

Adjust the background color of the date and time selection tool

Trying to customize the background of a datetime picker created using jquery.pttimeselect.js. Despite linking the correct css file (jquery.pttimeselect.css), I am unable to change the background color. Any suggestions on how to successfully modify the ba ...

Tips for globally overriding MUIv4 class in JSS for nested themes

Summary: Skip to EDIT2 MUIv4 has generated the following classes for me based on my nested theming: <label class="MuiFormLabel-root-121 MuiInputLabel-root-113 MuiInputLabel-formControl-115 MuiInputLabel-animated-118 MuiInputLabel-shrink-117 M ...

Display a hidden div upon loading the page if a certain condition is met

As a beginner in this field, I am struggling to assist a friend with a project. He needs a simple quote form that can generate HTML quotes for his client on a private WordPress page. The form should display a specific div based on the radio button selecti ...

"Can we have selection options or drop-down menus that are in line with today

Currently working on a website project for a client where I, as a designer learning to code, have integrated three select options. This is how it appears: The client's new requirement is that the arrival date should automatically display as the curr ...

The vertical dimension of an element does not increase

Currently, I am working on a webpage with a header, page content, and footer sections. The issue I'm facing is that I set the page's height to height :auto;, but it's not functioning as expected. I actually need the page to automatically ex ...

centered logo in a flexbox header

Having trouble with Flex for the first time. Despite reading and experimenting, I still can't figure it out. Any suggestions on how to accomplish this? Check out an example ...

Guide to configuring the overflow-y property for individual cells or rows in a Bootstrap-Vue table

Hello there, I am currently using Bootstrap-vue to display data that has been queried from a database. My goal is to have it displayed with an overflow-y style similar to this image. If you know how to achieve this effect, please share your solution. Here ...

What is the best way to add the SO-style <kbd> effect to my presentation made with HTML?

I'm currently utilizing reveal.js to construct an HTML-based presentation. My goal is to incorporate keyboard symbols like the ones found on SO and Github using the <kbd>SPACE</kbd> syntax, resulting in this glyph: SPACE. Despite attempti ...

Leverage the power of effekt in your AngularJS development

Can anyone demonstrate how to implement animation effects with AngularJS? Has someone created an example using Effeckt.css? ...

Is it possible to swap out the content within a <div> element with an external piece of HTML code using JQuery or JavaScript whenever the viewport dimensions are adjusted?

<html> <head> </head> function () { var viewportWidth = $(window).width(); if (viewportWidth < 700) { $('#wrapper').load('A.html'); }; <body> &l ...

Can you identify the selected item on the menu?

My goal is to highlight the menu item for the current page by adding a "current" class. I've tried several code snippets from this website, but most of them didn't work as expected. The code I'm currently using almost works, but it has a sma ...

Guide to adding checkbox IDs and inserting them into a textarea

Hello, my name is Prasath and I am currently learning about AJAX. I am working on a project involving seat layouts and finding it challenging to retrieve both the seat fare and seat number simultaneously. Is there anyone who can assist me in resolving this ...

Tips for establishing a universal onkeydown listener for all frames within a webpage?

Working with a complex legacy multi-frame webpage that needs to be compatible with IE-11 and responsive to hotkey events has brought up some challenges. It appears I can't simply declare a JavaScript method in the parent page. Rather, it seems that e ...