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

Is there a way to obtain HTML code within a contentEditable DIV?

When working in a contentEditable-DIV, my goal is to extract the HTML code from the starting position (0) to the end position where the user has clicked. <div id="MyEditableId" contentEditable="true"> 1. Some text 123. <span style="background-c ...

Text aligned vertically within an element using the table-cell display attribute in the Chrome browser

Struggling to align text inside an element styled with display: table-cell? The issue arises when dealing with multiline text in a tab format. Achieving the correct vertical-align: middle; requires displaying it as a table-cell, which works well in most ca ...

Determine the overall price of the items in the shopping cart and automatically show it at the bottom without the need for manual entry

Creating a checkout form that displays the total cost of products, subtotal, GST cost, delivery cost, and overall price. The goal is to calculate the total by adding together the costs of all products with the "price" class (may need ids) at a 15% increase ...

How to apply dynamic styling to a MatHeaderCell using NgStyle?

My goal is to dynamically style a MatHeaderCell instance using the following code: [ngStyle]="styleHeaderCell(c)" Check out my demo here. After examining, I noticed that: styleHeaderCell(c) It receives the column and returns an object, however ...

Customizing Eclipse Outline View for Cascading Style Sheets (CSS) Files

Is there a way to modify Eclipse's Outline view for CSS files? Specifically, how can I make the outline display comments and create collapsible ranges for groups of CSS rules? Include comments in the outline Create collapsible ranges for groups of ...

Organizing knockout data outcomes into two separate columns

Is there a way to split up this code into two columns using Knockout and HTML? I can do it easily in CSS, but the goal is to divide the results into segments 1-5 and 6-9. Here is the code snippet. Also attached is a screenshot for reference. Thank youhtt ...

Is there a way to enlarge images when hovered using canvas?

I came across a fascinating example at the following link: , where the images expand when hovered over. I am aware that this can be achieved using jquery, but I have concerns about its speed and reliability. I would like to experiment with d3.js, although ...

When additional elements follow, the button ceases to function properly in JavaScript

I am working on creating a text-based idle game that involves multiple buttons and text around them. However, I have encountered an issue where the functionality stops working when I try to add text after the "Work" button. The callback function is no lon ...

Creating a collapsing drop down menu with CSS

I utilized a code snippet that I found on the following website: Modifications were made to the code as shown below: <div class="col-md-12"> ... </div> However, after rearranging the form tag, the drop-down menu collapse ...

An HTML table featuring rows and columns that can be adjusted in size separately from the content within each cell

Looking to create an HTML table where the columns and rows can be sized independently of the cell content? If a row or column isn't large enough to display all the content, it should simply overflow behind the cell. A solution was found that worked in ...

How can I properly integrate jQuery libraries, along with CSS, in a create-react-app project?

I'm currently working on incorporating the select2 jquery library into my React application, which was created using create-react-app. After adding jquery and select2 to my package.json file, I was able to get the javascript functionality to work pro ...

Difficulty with animated presentations

As a developer with limited CSS experience, I am trying to create a CSS3 slideshow using only two images. After discovering some interesting code for this purpose, which can be found here, I decided to make a small change to the original code (specifically ...

Navigating through various div elements in Javascript and sending parameters to a script

Context In my project, I am using PHP to generate a series of voting sections. Each section follows the same format except for a unique number assigned to it, which increases with each iteration of the PHP loop. To keep track of the unique numbers, I uti ...

What is the best way to implement this design using CSS or JavaScript?

I would like to enhance the appearance of my school website during these challenging times of the pandemic by adding some CSS or JavaScript elements. However, I am unsure how to go about it. ...

Why does Material-UI TableCell-root include a padding-right of 40px?

I'm intrigued by the reasoning behind this. I'm considering overriding it, but I want to ensure that I'm not undoing someone's hard work. .MuiTableCell-root { display: table-cell; padding: 14px 40px 14px 16px; font-size: 0. ...

What is the best way to expand the navigation bar: should I add a side div or incorporate a background image?

I am encountering two issues that I need help solving. My first problem involves stretching out the navigation bar to fill the height and length of the adjacent div (div#textarea) while also keeping the text of the menu centered within that div. The seco ...

Challenged with selecting an item within select2 due to the presence of a lower-down multiple select

Why am I unable to select options 2 & 3 when I open #s1? Instead, when I click on them, the cursor goes into #s2. How can I resolve this issue? I initially considered that it might be related to the z-index, but after attempting to adjust it, the prob ...

What could be causing the issue of dynamic meta open graph tags not functioning properly?

For my current project, I am utilizing Strapi as the CMS and Next.js. My task is to generate meta open graph tags dynamically. However, after deployment, when I attempt to share my website link on social media platforms such as Facebook or WhatsApp, the ti ...

Error in scrolling previews detected in Jssor horizontal template maker

I've been working with Jssor Slider Maker and I'm using the vertical preview template that features two columns on the left side and a maximized image on the right side. After pulling the code from the developers pack, it includes scripts, CSS an ...

Is the first child component of Material UI Stack not properly aligned?

Is there a CSS issue that needs fixing? I am working on creating a vertical list of checkboxes with labels using the <Stack /> component from Material UI. I have tried implementing this in the sandbox provided (check out demo.tsx): https://codesandb ...