Having trouble selecting links in the navigation bar

Just getting started with HTML/CSS and designing a website with buttons. Got some buttons up and running perfectly fine. But now, I'm working on a navigation bar with anchors inside. The problem is that while I can see the anchors when I open the website, I just can't click on them. Strangely, all my other buttons are working without any issues. Could it possibly be related to the nav id?

        .menubalk{
    padding:25px;
    
    }
    .menubalk ul{
    list-style:none;
    display:inline;
    margin-left:0;
    padding:375px;
    }
    .menubalk li{
    display:inline;
    }
    
    .menubalk a{
    color:black;
    background-color:#0072BB;
    text-transform:uppercase;
    font-size: 12px;
    font-weight:bold;
    padding: 20px;
    border-radius:5px;
    }
    .content{
    background-color:#0072BB;
    border-radius:25px 25px 25px 25px;
    margin-left:175px;
    padding:25px;
    
    }
    p,h2,img{
    margin:0;
    }
    
    nav{
    background-color:#0072BB;
    float:left;
    width:150px;
    border:10px solid white;
    border-radius:25px 25px 25px 25px;
    }
    #wrapper{
    margin:0px auto 0px auto;
    min-width:500px;
    max-width:1800px;
    
    }
<div id="wrapper">
<header>
<div class="logo">
<img src="../Afbeeldingen/QualitySigns.png" alt="logo Quality Signs" height="300" width="384">
<div class="logotekst">
<p>
Signalisatie van hoge kwaliteit
</p>
</div>
</div><!--einde logo-->
<div class="menubalk"><!-- begin menubalk-->
<ul>
<li><a href="#">Projectpagina</a></li>
<li><a href="#">CV-pagina</a></li>
<li><a href="#">Extra link</a></li>
</ul>
</div><!-- einde menubalk-->
</header>
<nav>
<ul>
<li><a href="index.html">Over ons</a></li>
<li><a href="#">Productie</a></li>
<li><a href="#">Verhuur</a></li>
<li><a href="#">Plaatsing</a></li>
</ul>
</nav>

Would really appreciate if someone could help me figure out this problem. Thank you!

Answer №1

It seems that Nathan Fries' response hit the nail on the head. The issue lied in the padding, although it appears you were attempting to center the top navigation bar using it.

Here is an enhanced version of your styling with functional links and a perfectly centered navbar! By utilizing percentages and auto margins, the navbar remains centered even when adjusting the browser window size.

Best of luck with your project!

    .menubalk {
      text-align: center;
      width: 100%;
      margin: 5% auto auto auto;
    }

    .menubalk ul{
    list-style:none;
    }

    .menubalk li{
    display:inline;
    }
    
    .menubalk a{
        color:black;
    background-color:#0072BB;
    text-transform:uppercase;
    font-size: 12px;
    font-weight:bold;
    padding: 20px;
    border-radius:5px;
    }

    .content{
    background-color:#0072BB;
    border-radius:25px 25px 25px 25px;
    margin-left:175px;
    padding:25px;
    
    }

    p,h2,img{
    margin:0;
    }
    
    nav{
    background-color:#0072BB;
    float:left;
    width:150px;
    border:10px solid white;
    border-radius:25px 25px 25px 25px;
    }
<div id="wrapper">
<header>
<div class="logo">
<img src="../Afbeeldingen/QualitySigns.png" alt="logo Quality Signs" height="300" width="384">
<div class="logotekst">
<p>
Signalisatie van hoge kwaliteit
</p>
</div>
</div><!--einde logo-->
<div class="menubalk"><!-- begin menubalk-->
<ul>
<li><a href="#">Projectpagina</a></li>
<li><a href="#">CV-pagina</a></li>
<li><a href="#">Extra link</a></li>
</ul>
</div><!-- einde menubalk-->
</header>
<nav>
<ul>
<li><a href="index.html">Over ons</a></li>
<li><a href="#">Productie</a></li>
<li><a href="#">Verhuur</a></li>
<li><a href="#">Plaatsing</a></li>
</ul>
</nav>

Answer №2

The issue with the .menubalk ul selector is that the padding value is set to 375px, causing the element to overlap the links below.

.menubalk ul{
    list-style:none;
    display:inline;
    margin-left:0;
    padding:375px;
}

For a correct implementation, refer to the updated code snippet below:

.menubalk{
    padding:25px;

}
.menubalk ul{
    list-style:none;
    display:inline;
    margin-left:0;
    padding:0px;
}
.menubalk li{
    display:inline;
}

.menubalk a{
    color:black;
    background-color:#0072BB;
    text-transform:uppercase;
    font-size: 12px;
    font-weight:bold;
    padding: 20px;
    border-radius:5px;
}
.content{
    background-color:#0072BB;
    border-radius:25px 25px 25px 25px;
    margin-left:175px;
    padding:25px;

}
p,h2,img{
    margin:0;
}

nav{
    background-color:#0072BB;
    float:left;
    width:150px;
    border:10px solid white;
    border-radius:25px 25px 25px 25px;
}
#wrapper{
    margin:0px auto 0px auto;
    min-width:500px;
    max-width:1800px;

}
<div id="wrapper">
    <header>
        <div class="logo">
            <img src="../Afbeeldingen/QualitySigns.png" alt="logo Quality Signs" height="300" width="384">
            <div class="logotekst">
            <p>             
                Signalisatie van hoge kwaliteit
            </p>
            </div>
        </div>  <!--einde logo-->
        <div class="menubalk">  <!-- begin menubalk-->
            <ul>
                <li><a href="#">Projectpagina</a></li>
                <li><a href="#">CV-pagina</a></li>
                <li><a href="#">Extra link</a></li>
            </ul>
        </div><!-- einde menubalk-->
    </header>       
    <nav>
        <ul>
            <li><a href="index.html">Over ons</a></li>
            <li><a href="#">Productie</a></li>
            <li><a href="#">Verhuur</a></li>
            <li><a href="#">Plaatsing</a></li>
        </ul>   
    </nav>

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

Building a Next.js project encounters issues with the <img> HTML tag

Lately, I've dived into creating websites using Next.js and have been experimenting with a combination of Image and img for different purposes. I am aware that Image is an integral part of Next.js and the preferred option, but there are instances whe ...

Create a server directory structure that populates multiple HTML dropdown lists using either jQuery or AJAX

As a novice navigating jQuery and Ajax, I find myself faced with a specific challenge. My current situation involves a structured set of directories on a server. My goal is to populate a dropdown dynamically with this file hierarchy. Upon click ...

Aligning CSS Divs with Changing Content

Can someone help me with a CSS and DIV tags issue? I have a dynamic webpage and need guidance on creating a container DIV. Depending on the scenario, this container DIV will either hold one DIV with 50% width that needs to be centered or two side-by-side D ...

Expand the <div> to match the complete height of its containing <div> element

There are multiple div blocks within a parent block: one for the menu on the left, and one for the text on the right. How can you make the right inner block stretch to the full height of the parent block like the left one? The parent block has a minimum he ...

Obtaining a binary value in the switch component of materialize framework with Typescript

Is there a way in Typescript to assign a value of 1 when a checkbox is checked and 0 otherwise? I am working on a project that uses the materialize framework. Below is the code snippet in question: <div class='switch'> <label&g ...

What is causing my mobile version not to resize and adjust to fit the screen properly?

Currently utilizing Bootstrap 4 along with the viewport meta tag, %meta{:content => "width=device-width, initial-scale=1, shrink-to-fit=no", :name => "viewport"}/ Even after hiding all images with .hidden-xs-up, the display on Chrome mobile appear ...

Having difficulty modifying the width of the BODY element using CSS

For my webpage, I want the body to have a silver background that fills only 75% of the page. This means that only 75% of the page will be painted silver, while the remaining part will be left unused and painted according to the browser's defaults. The ...

Assigning the href attribute dynamically

How can you dynamically set the href attribute of the <a> tag using jQuery? In addition, what is the method for retrieving the value of the href attribute from the <a> tag with jQuery? ...

How can I ensure a div expands over another element when hovering the mouse?

I have a development div in the footer with a hover effect that expands it. However, it is currently growing underneath the top element on the site. I want it to expand on top or push the element above. Website: I've tried using position, float, and ...

PHP file secured to only accept variables posted from HTML form

This is a basic HTML/AJAX/PHP script I have implemented. <form id="new_user" action="" method="post"> <div class="col-md-3 form-group"> <label for="username">Username</label> <input type="text" class="form-control" name ...

I am attempting to trigger a mouseup event following a mousedown action

elements[0].onmousedown = function(){ console.log('screen clicked.'); triggerMouseUp(); }; I just need to incorporate a function in my code that simulates mouseup event, even when the user is still holding down the click button. e ...

Tips for aligning a drop down list in the center

I need help center-aligning my dropdown list to match the buttons that are also center-aligned. Do you have any suggestions on how I can achieve this using .css? <h4 id="carbCount" class="pageElement">The Carb Count is 0</h4><br /> &l ...

What is the process for creating a List Grid View utilizing this particular code?

I attempted to modify the stylesheet extensively and also created a small function in JavaScript, but unfortunately it did not yield the desired results. <div class="row featured portfolio-items"> <div class="item col-lg-5 col-md-12 col-xs ...

The error message "invalid module name" is preventing Phoenix from creating an HTML template

Encountering issues while trying to run the phx.gen.html templates. Below is the command that I am attempting: mix phx.gen.html Shipments shipmentroutes shipmentroute address:string date:string groups_involved:string An error message is displayed as fol ...

Attempting to evenly distribute items within a div container

My goal is to arrange the items in the container div evenly on a single line. I want them to be spaced out like this: I'm struggling to achieve this layout where the items are on the same line and evenly distributed within the available space. This ...

Display a preview window once the image has been chosen

I have created an image preview div to show the selected image's thumbnail. Everything was working fine so far. But now, I want this div to be hidden when the page initially loads and only become visible when a user selects an image to upload. Here is ...

Anchor point located within a scrollable div with a fixed position

A unique challenge has presented itself with a div called #results that appears when words are entered into a text box, triggering relevant results. This particular div is fixed and scrollable, with pagination located at the bottom of the scroll. The iss ...

What is the procedure for utilizing Javascript to redirect a user on a website back to the login page if necessary?

Is there a way to redirect a website user back to the login page if they try to access a secure page without logging in first? I'm looking to implement this using JavaScript and cookies. Any suggestions or ideas on how to achieve this seamlessly for t ...

Is it possible to close the navigation menu by clicking on a link or outside of the navigation area?

Hey everyone, I've recently dived into the world of web design and encountered my first hurdle. I need your expertise to help me solve this problem. How can I modify my JavaScript to close the NAV element by clicking on one of the links or outside t ...

Achieve a floating right alignment of an unordered list navigation using CSS without changing

I am currently implementing a jquery navigation system which can be found at this link: http://css-tricks.com/5582-jquery-magicline-navigation/ My goal is to have the navigation bar float to the right without changing the order of items (e.g. home, contac ...