The execution of a link in Firefox is blocked only when an active div is shown

The code includes an <a href> element that wraps around two div elements. One of the divs is only displayed when the link is clicked, and it appears above the other div. This setup serves as a visual feedback mechanism for user interaction.

To see and test this in action, visit: https://jsfiddle.net/pjgdtade/2/

a {
  text-decoration: none;
  display: flex;
  position: relative;
  width: 328px;
}

div.tile {
  position: relative;
  padding: 12px 10px;
  box-sizing: border-box;
  background-color: white;
  color: black;
  display: block;
  width: 328px;
  margin: 0;
  box-shadow: 1px 2px 4px 0 #e0e0e0;
  border: solid 1px #dcdcdc;
}

div.link-active-cover {
  background: rgba(220, 220, 220, 0.6);
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: none;
}

a:active div.link-active-cover {
  display: block;
}
<a href="https://www.google.de" target="_blank">
  <div class="tile">
    This is some content in a clickable box.
  </div>
  <div class="link-active-cover"></div>
</a>

In Chrome browser, everything functions correctly as intended. However, in Firefox, clicking on the link does not trigger its execution. The div.link-active-cover displays upon click, but the new page fails to open.

An interesting observation is that if the div.link-active-cover is initially visible (no display: none), both the div shows up and the link works properly.

Is there something wrong with my implementation or could this be a bug specific to Firefox?

Answer №1

Perhaps the reason is that when a click event occurs (following a mouseup), the cursor is not positioned on the initially clicked element.

However, a viable solution would involve adjusting the opacity:

a {
  text-decoration: none;
  display: flex;
  position: relative;
  width: 328px;
}

div.tile {
  position: relative;
  padding: 12px 10px;
  box-sizing: border-box;
  background-color: white;
  color: black;
​  display: block; 
​  width: 328px;
  margin: 0;
  box-shadow: 1px 2px 4px 0 #e0e0e0;
  border: solid 1px #dcdcdc;
}

div.link-active-cover {
  background: rgba(220, 220, 220, 0.6);
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: .001;
}

a:active div.link-active-cover {
  opacity: 1;
}
<a href="https://www.google.de" target="_blank">
  <div class="tile">
    This is some content in a clickable box.
  </div>
  <div class="link-active-cover"></div>
</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

Node JS login leads to fetching /favicon.ico

I've implemented a login/register system using express (passport) on my website. I'm facing an issue where after the user logs in, they are redirected to /favicon.ico instead of the saved originalUrl. Can anyone help me identify what might be cau ...

Using a batch file to send an email

I have a goal to create an autorun file that can be placed on an external drive, flash disk, or CD. When executed, this file will run a series of commands that eventually send the computer's IP information back to me. Here is what I have so far... Th ...

Separate the business logic from the HTML code in Angular to prevent repetition and make the code

I have a lengthy HTML code with ngSwitch for 3 cases and 4 small cases within the default case, all using the same icon structure. How can I shorten my HTML code and eliminate business logic from it? The hierarchy to display different icons is: Servicefl ...

How can I use JavaScript or CSS to identify the specific line on which certain words appear in the client's browser?

Imagine I have the following HTML structure: <div> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco labor ...

What is the process of providing a thumbnail image to external websites?

When a user shares a link from a website on social media platforms like Reddit or Facebook, an image is usually attached to it. Is there a way to specify which image should appear in the header of the HTML file? I assume that there must be a meta tag, lik ...

When the fullscreen modal is opened, the initial image displayed is not the same as the one that was clicked on

Seeking assistance: I've been struggling with a problem for quite some time now and could really use some help from you guys. My issue involves an 'AngularJS' webapp that retrieves posts from an 'FB page' via 'OpenGraph' ...

Incorporating External Content into Your HTML Website

Looking to incorporate third-party content in the form of an HTML page within my own website, I considered utilizing iframes. This would allow me to embed the external HTML page within my site while keeping their libraries and CSS separate from mine. Howe ...

Issue with bootstrap: the navbar highlight and anchor href are not functioning as intended

I'm currently working on creating a Navbar and implementing the navbar highlighting feature using the active bootstrap class. Below is the code I have tried: <!DOCTYPE html> <html lang="en"> <head> <!-- Bootstrap CSS ...

Attempting to make initials fade and slide out upon mouseover using jQuery

I've been experimenting with jQuery to create a unique effect where hovering over my initials in the header expands the containing div and reveals my full name letter by letter. However, I'm facing some challenges and could use some guidance on t ...

Mobile view doesn't quite center using flexbox, even though it works fine on desktop

Utilizing flexbox, the two distinct sentences that form the content of the page are centered. However, upon viewing the website on my mobile phone, the second sentence appears aligned to the left side. Here's how the site appears on a phone I've ...

Unraveling HTML elements within a string using MongoDB: A step-by-step guide

Currently, I am in the process of creating a blog from scratch as a way to enhance my skills. The posts' content is stored as a long string in MongoDB with some random HTML tags added for testing purposes. I am curious about the conventional method fo ...

Can you provide an example of JSON for a MultiStep Form that includes a variety of control types for viewing

Could someone please provide me with JSON examples of multi-step forms that include various types of controls such as radio buttons, checkboxes, dropdown menus, and calendars? I am in need of JSON for both the view and edit forms. Your help would be grea ...

Is it possible for Firefox's Inspect Element Network feature to detect JSON strings as effectively as Chrome can

My goal is to analyze json strings within REST messages. While Chrome offers options to do this through Inspect -> tab Network, I am unable to locate the json string in Firefox. Is this functionality supported by Firefox? I will provide an example from ...

Eliminate excess space around images in Bootstrap

I have an image tag with a padding applied to it. I am using the Bootstrap CSS framework. Currently, there is a white background behind the image that I want to remove and make it partially transparent instead. The image is in PNG format, so I suspect the ...

Event dedicated to the selection of mobile options

I am facing an issue with binding an event to the options of a select tag on mobile devices. The code inside the click event handler doesn't seem to be working and I'm unsure of the reason behind it. My assumption is that perhaps the click event ...

A dynamic homepage that transforms upon login, created without the use of any content management systems

I am embarking on creating a website with registration and login features without relying on any CMS, using only pure HTML/CSS and other necessary tools. My main confusion lies in how I can develop a homepage that can cater to any visitor by displaying rel ...

Choose items that do not contain ::before or ::after pseudo-elements

I am looking to apply a specific font style to all text on a page except for Font Icons (specifically Font Awesome) which do not share a common class. In order to achieve this, I need to target elements in one of the following ways: Elements that do not ...

Align columns to the right and left using Bootstrap

It should be simple enough, but I can't seem to find my mistake. Goal: The entire markup should be centered with a width of col-10. Within the same 10-column width, there should be two divs each taking up 50% of the space. Using Bootstrap 5, for so ...

css position:absolute stacked

Looking for a solution, I'm trying to include a side menu (navbar) on my page by using position: fixed. However, I am facing an issue where all the HTML elements I attempt to add are ignoring it. Check out the positioning problem here. ...

restructure the HTML based on a jQuery condition

Using jQuery to Refresh HTML Content function(data) { if(data === "importtrue") { $('#rebuildme').//function like .html } else { $('#rebu ...