Creating a dropdown menu with HTML and CSS is causing me a major migraine

<div class="fbtop">
  <img src="https://static.solidshops.com/1441/files/Logo-site.png" title="Pieke Wieke" alt="Pieke Wieke">
  <h2 class="title">Handcrafted with love</h2>


  <ul class="dropdown">
    <li>
  <a href="https://piekewieke-fb.solidshops.com/category/sewing-supplies">Sewing Supplies</a>

     <ul class="sub_menu">
            <li>
      <a href="https://piekewieke-fb.solidshops.com/category/sewing-supplies-assorted-items">Assorted Items</a>
              </li>
            <li>
          <a href="https://piekewieke-fb.solidshops.com/category/sewing-supplies-pins">Pins</a>
              </li>
            <li>
      <a href="https://piekewieke-fb.solidshops.com/category/sewing-supplies-needles">Needles</a>
              </li>
          </ul>
      </li>
    <li>
  <a href="/category/fabrics">Fabrics</a>

  <ul class="sub_menu">
            <li>
      <a href="/category/fabrics-solid-colors">Solid Colors</a>
              </li>
            <li>
      <a href="/category/fabrics-cotton">Cotton</a>
                <ul>
                    <li>
          <a href="/category/fabrics-cotton-pieke-wieke-for-soft-cactus">Pieke Wieke for Soft Cactus</a>
        </li>
                    <li>
                        <a href="/category/fabrics-cotton-soft-cactus">Soft Cactus</a>
        </li>
                    <li>
          <a href="/category/fabrics-cotton-printed-cotton">Printed Cotton</a>
        </li>
                    <li>
          <a href="/category/fabrics-cotton-basics">Basics</a>
        </li>
                    <li>
          <a href="/category/fabrics-cotton-stretch-cotton">Stretch Cotton</a>
        </li>
                  </ul>
              </li>
            <li>
      <a href="/category/fabrics-printed">Printed</a>
              </li>
            <li>
      <a href="/category/fabrics-stretch-cotton">Stretch Cotton</a>
              </li>
            <li>
      <a href="/category/fabrics-knit">Knit</a>
              </li>
            <li>
      <a href="/category/fabrics-flannel">Flannel</a>
              </li>
            <li>
      <a href="/category/fabrics-gabardine">Gabardine</a>
              </li>
            <li>
      <a href="/category/fabrics-corduroy">Corduroy</a>
              </li>
            <li>
      <a href="/category/fabrics-lining">Lining</a>
              </li>
            <li>
      <a href="/category/fabrics-teddy-fleece">Teddy Fleece</a>
              </li>
            <li>
      <a href="/category/fabrics-woven">Woven</a>
              </li>
          </ul>
      </li>
    <li>
  <a href="/category/iron-on-vinyl">Iron-On Vinyl</a>
      </li>
    <li>
  <a href="/category/workshops">Workshops</a>
      </li>
    <li>
  <a href="/category/gift-certificates">Gift Certificates</a>
      </li>
    <li>
  <a href="/category/vlieseline">Interfacing</a>
      </li>
    <li>
  <a href="/category/haberdashery">Haberdashery</a>

  <ul class="sub_menu">
            <li>
      <a href="/category/haberdashery-ribbon">Ribbon</a>
              </li>
            <li>
      <a href="/category/haberdashery-thread">Thread</a>
              </li>
            <li>
      <a href="/category/haberdashery-zippers">Zippers</a>
              </li>
            <li>
      <a href="/category/haberdashery-piping">Piping</a>
              </li>
            <li>
      <a href="/category/haberdashery-bias-tape">Bias Tape</a>
              </li>
            <li>
      <a href="/category/haberdashery-elastic">Elastic</a>
              </li>
          </ul>
      </li>
  </ul>
</div>

Here is a traditional dropdown menu created using CSS. To view its functionality, you can visit http://jsfiddle.net/W6Rhe/.

However, there seems to be an issue with the menu. When selecting the first item "Sewing Supplies," the first sub-menu item should appear in red but shows up as white instead.

A similar problem occurs when clicking on "Fabrics" and then selecting the "Cotton" sub-menu.

Interestingly, changing all the links to relative URLs resolves the issue and displays all items in red color as intended.

I'm puzzled by what could be causing this strange behavior. Any insights would be greatly appreciated!

P.S. This has been tested on Chrome. P.P.S. Changing the URLs to anything other than their current format seems to eliminate the problem. Quite bizarre indeed...

Answer №1

Take a look at this snippet of code:

ul.navbar li a:visited,
ul.navbar li a:hover
{ 
    color:#ffffff;
}

This particular piece of code is specifically changing the color of visited links to white.

The reason behind this change in color when using a relative URL is due to the fact that the browser no longer recognizes it as a visited link, since it is a different path.

Answer №2

I recently uncovered the culprit, all thanks to Andy for guiding me in the right direction:

ul.dropdown ul li a:hover,
ul.dropdown ul li a:active,
ul.dropdown ul li a:link             {color: #e10707; }

Andy pointed out that the links appearing white were actually links affected by the :visited attribute set as #fff or white :)

In the previous code block, one state was overlooked – the a:visited color wasn't being defined as red, which is why it remained white.

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

Having trouble retrieving a base64 encoded image from a MySQL database using PHP

Within my MySQL database, there is a longblob field that stores a binary value representing an image uploaded through my website. I am currently attempting to retrieve the image using: <?php while($record = mysqli_fetch_assoc($result)): ?> <div&g ...

Utilizing nested HTML within an HTML tag

Recently, I've been exploring the concept of nested HTML in Bootstrap. While following a tutorial on using Popovers, I encountered the following code; <button id="btn3" type="button" class="btn btn-primary show" ...

Unable to delete data in Laravel 8

I am new to Laravel and facing an issue when trying to delete a row with a modal. The problem is that only the first row is getting removed and I can't figure out the reason. Here is my modal setup: <p class="card-text"><small clas ...

What is the best way to center the input on the page?

Does anyone know how to align the <input type="text"> in the center? I'm trying to create a login form but having trouble with positioning the input element. ...

Identifying the pressing of the enter key in an input field

Currently, I am developing an innovative IFrame browser that features an omnibox (identified as "address") and a "GO" button (identified as "submit"). One of the key challenges I'm facing is detecting when the user inputs information and hits the Ente ...

Using CSS, eliminate the drop-down menu from the main navigation on Squarespace

While working on my Squarespace website, I've been impressed with how the FAQ page/questions are structured. However, a drawback is that it creates a clunky drop-down menu when hovering over the FAQ tab in the main navigation. You can see an example ...

MUI: tips for positioning text next to each other on a page

I need assistance aligning numbers and text side by side, similar to the image shown here: https://i.sstatic.net/gXzOM.jpg However, there is a margin to the right of the text(MASTER I 406), causing the numbers to not be in the correct position. Currently, ...

Guide on incorporating the font-awesome library in your project

Forgive me if this sounds like a silly question, but I am completely new to javascript and its libraries. I stumbled upon a similar issue as described in this thread, where the accepted solution included the following line: <link rel="stylesheet" href ...

Shadcn/ui Select - update the state upon user's item selection

I am currently using Shadnui and trying to accomplish a simple task of allowing the user to select a number from 1 to 6. I want the state to update when the user makes a selection. While researching, I came across this thread: Shadcn ui select component s ...

A dynamic Java web framework that combines RESTful JSON services with the power of HTML5 and jQuery AJAX functionality

As we approach the year 2013, the era of HTML5, jQuery has solidified itself as the go-to standard for web Javascript development. Back in 2010, this link was quite popular: I am searching for a Java web framework that can expose domain classes through R ...

Validating Date Input in HTML and JavaScript Text Fields

When designing my form, I wanted to ensure that users could only input digits and hyphens in a text field where they enter a date. However, I encountered some difficulty implementing this feature. Currently, the field only accepts digits and removes any le ...

Utilizing the predefined color palette of Bootstrap for styling text in a

When creating a form using Bootstrap, I want to add some text in a color that matches the brand color used for buttons. While I am aware of the text colors like text-primary available in Bootstrap, I prefer to use button colors for my text. I attempted th ...

Stylishly Select with Bootstrap 4

Currently, I am utilizing Angular 2 with bootstrap 4 and have implemented the following select element: <div class="form-group"> <label class="col-md-4 control-label" for="OptionExample">Choose an option:</label> <div class="c ...

CSS - Customizing the appearance of consecutive child divs

I'm struggling with adjusting the margin between two child divs when they follow each other. The current margin is set at 3rem, but I want it to be 1rem if both child containers have the class "narrow": Is there a way to achieve this without changing ...

I'm having trouble with Gutters GX and GY not functioning properly in Bootstrap, HTML, and CSS

I attempted to incorporate gutters into my Bootstrap grid layout, however, they are not showing up as expected. I am following the guidelines provided on the Bootstrap documentation, but for some reason, the gutters are not appearing. <!DOCTYPE html> ...

The `innerHTML` function is responsible for closing HTML

My switch structure is set up as follows: switch (ratio) { case "16:9": imgContainer.innerHTML = '<img src="images/test-rata-de-aspect.jpg">' break case "4:3": imgContainer.innerHTML = '<img src="image ...

Relocate the preview division below the button in the Kartik File Input Widget

There are two input file buttons that allow users to upload an image on each button. Upon selecting an image, a preview of the image will be displayed above the button. The current layout is shown here: When images of different sizes are uploaded, the but ...

Learn the art of closing an AngularJS accordion automatically when another accordion is opened within an AngularJS application

I have encountered an issue with the AngularJS accordion functionality. It seems that when I have multiple accordions, such as accordion-1, accordion-2, and accordion-3, they all open simultaneously if clicked on individually. My main concern is: How can ...

Adapting the position of a table row in AngularJS based on the

I need assistance with creating a dynamic table-row that moves to indicate the current time in a table filled with timestamps. <table> <tr ng-repeat="timestamp in timestampArray"> <td>{{timestamp}}</td> </tr> ...

What sorcery does Facebook use to alter the URL without triggering a page reload?

Similar Question: How can I update window location without a reload and # hack? Facebook and Ajax What method does Facebook use to change the URL without reloading the page? In the past, Facebook utilized the hash (#) symbol to prevent the page f ...