Preventing users from clicking on links unless they double click by using CSS rotation

I'm struggling to figure out why only the white portion of my links is clickable. The links are designed as "3D" buttons using CSS rotate transitions, but I can't seem to fix the issue. Any assistance would be greatly appreciated!

Check out the codepen link.

Here is the HTML:

<nav>
    <ul>
        <li><a href="index.html" data-hover="Home">Home</a>
        </li>
        <li><a href="plans.html" class="current" data-hover="Plans">Plans</a>
        </li>
        <li><a href="#" data-hover="Forums">Forums</a>
        </li>
        <li><a href="team.html" data-hover="Team">Team</a>
        </li>
    </ul>
</nav>

CSS:

* {
    box-sizing: border-box;
}

nav {
    background: #e9e9e9;
    margin: -1rem 0rem;
    z-index: 0;
}

nav ul {
    list-style: none;
}

nav ul li {
    display: inline-block;
    text-transform: uppercase;
    font-size: 1.5rem;
    letter-spacing: 0.05rem;
}

nav ul li a {
    display: inline-block;
    padding: 1rem;
    color: #000;
    text-decoration: none;
    transition: transform 0.3s ease 0s;
    transform-origin: 50% 0px 0px;
    transform-style: preserve-3d;
}

nav ul li a.current {
    color: #ffc400;
}

nav ul li a:hover {
    background: #e9e9e9;
    color: #000;
    transform: rotateX(90deg) translateY(-22px);
}

nav ul li a::before {
    position: absolute;
    top: 100%;
    left: 0px;
    width: 100%;
    padding: 4px 0px;
    text-align: center;
    line-height: 50px;
    background: none repeat scroll 0% 0% #ffc400;
    color: #FFF;
    content: attr(data-hover);
    transition: #ffc400 0.3s ease 0s;
    transform: rotateX(-90deg);
    transform-origin: 50% 0px 0px;
}

Answer №1

One issue that arises is when the link is translated out of view, rendering it unclickable:

nav ul li a:hover {
    background: #e9e9e9;
    color: #000;
    transform: rotateX(90deg) translateY(-22px);
}

An easy fix for this problem is to wrap an a element around the li and change the existing a to a div, like this:

This way, both the div and li elements undergoing translation and rotation are enclosed within the clickable link.

<a href="#">
    <li>
        <div data-hover="Forums">Forums</div>
    </li>
</a>

CSS:

* {
    box-sizing: border-box;
}

nav {
    background: #e9e9e9;
    margin: -1rem 0rem;
    z-index: 0;
}

nav ul {
    list-style: none;
}

nav ul li {
    display: inline-block;
    text-transform: uppercase;
    font-size: 1.5rem;
    letter-spacing: 0.05rem;
}

nav ul li div {
    display: inline-block;
    padding: 1rem;
    color: #000;
    text-decoration: none;
    transition: transform 0.3s ease 0s;
    transform-origin: 50% 0px 0px;
    transform-style: preserve-3d;
}

nav ul li div.current {
    color: #ffc400;
}

nav ul li div:hover {
    background: #e9e9e9;
    color: #000;
    transform: rotateX(90deg) translateY(-22px);
}

nav ul li div::before {
    position: absolute;
    top: 100%;
    left: 0px;
    width: 100%;
    padding: 4px 0px;
    text-align: center;
    line-height: 50px;
    background: none repeat scroll 0% 0% #ffc400;
    color: #FFF;
    content: attr(data-hover);
    transition: #ffc400 0.3s ease 0s;
    transform: rotateX(-90deg);
    transform-origin: 50% 0px 0px;
}

To ensure everything functions properly, apply styling to the a element:

nav ul a {
    text-decoration: none;
}

For the updated pen, click here.

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

What steps can I take to prevent a css-generated svg file from occupying more space than the original image? My wave appears to be 239px tall, while the svg file is a massive 1500px in height

I utilized an online tool to generate custom SVG CSS at this link: Upon implementing it on my webpage, the rendering seems correct in terms of height and width. However, upon inspecting the page, I noticed that the SVG file dimensions are 1512px by 1512px ...

Is there a simpler method to enable built-in CSS-Sass in Next.js without the need for excessive configuration?

Is there a way to maintain the built-in CSS/SASS feature in Next.js without extensive configuration? Utilizing the built-in CSS/SASS is convenient, but introducing less to next.config.js triggers the disabling of this feature, requiring manual configurati ...

Comparison of universal and descending selector in CSS

Can someone clarify when to use the universal selector versus the descendant selector in CSS? I've tried finding a clear explanation, but haven't come across one that explains the difference and when each should be used: div * .test{ color: re ...

I'm having trouble adjusting the width of my input using percentages with bootstrap, can anyone help me figure out why

Can anyone help me solve a challenge I'm facing with styling my input field without it becoming too large? Currently, when I apply the w-25 class to the input (which sets its width to 25%), the width adjusts based on its original size rather than that ...

Tips for attaching an image to an email

Can anyone assist me with an HTML form that sends emails using PHP with image attachments? I have tried various codes, but none of them seem to work properly. The message gets sent with all the texts and even the image name, but the actual image is missing ...

The Bootstrap modal's submit button refuses to be clicked

I have a unique challenge on my hands - dynamically loading a table within my page where each row is editable in a Bootstrap modal and deletable using multiple checked checkboxes through ajax. Everything works smoothly at first, with the submit button insi ...

Secondary menu supersedes primary dropdown menu

Having trouble getting a vertical dropdown menu to work properly, with the submenus overriding the main menu. I've searched everywhere for a solution but can't seem to find one. Anyone out there who could help me figure this out? Here's the ...

placing one SWF file above another

Is it feasible to layer multiple SWF files on top of one another directly? I have been experimenting with divs and different z-index values, but I am unsure about how the Flash player comes into play. Is my assumption correct that each SWF has its own indi ...

What could be causing the issue of this JQuery dropdown plugin not functioning properly on multiple dropdowns?

I have implemented a JQuery plugin for dropdown menus that can be found at the following link: https://code.google.com/p/select-box/ Currently, I am facing an issue where the script only seems to work for the first dropdown menu out of 4. I am unsure abo ...

Dynamic card resizing to fit changes in window size

Hey, I'm currently working on a card layout and have hit a roadblock. I'd like the images to shrink as the window size decreases proportionally. Goal: Images should decrease in size until 600px width while staying centered up to that point. I& ...

Iterate over JSON dates in JavaScript

Trying to utilize JavaScript in looping through a JSON file containing time periods (start date/time and end date/time) to determine if the current date/time falls within any of these periods. The provided code doesn't seem to be working as expected. ...

Exploring the world of web scraping by using Python to loop through HTML elements

Created a Python script to extract information from the website regarding its asset listings. So far, I have successfully retrieved the name of the first coin "Bitcoin," but I'm unable to get the ticker. With 27 pages on the site, each containing 40 ...

Positives and negatives images for accordion menu

I have successfully created an accordion list using HTML, CSS, and JavaScript. However, I would like to enhance it by adding a plus and minus picture in the left corner of the heading. Is there a way to achieve this functionality? I have two images that I ...

What is the method for displaying Facebook comments alongside the WordPress comments count?

I am currently using a template theme that initially had WordPress comments enabled on the website. By implementing the Facebook Comments plugin, I have successfully replaced Wordpress comments with Facebook Comments. **However, there seems to be an issue ...

What is the best way to ensure items are aligned to the top of the navbar as a picture is enlarged?

I have searched through various similar questions, but none of them have provided a solution to my specific issue. I have attempted multiple suggestions, but none have been successful. (I am working with bootstrap4) Here is the html code I am using: < ...

Exploring the Power of JQuery with Hover Effects and SlideToggle

I was struggling to keep the navbar displaying without it continuously toggling when my pointer hovered over it. I just wanted it to stay visible until I moved my pointer away. <script> $(document).ready(function(){ $(".menu-trigger").hover(funct ...

Eliminating the Scrollbar from Bootstrap 4 DataTable Causes Table Width to Decrease

My tables are causing a horizontal scroll bar to appear when converted to Bootstrap data tables. Adding the "p-3" class to the table's div for padding eliminates the scroll bar but also narrows the table. Is there a solution to removing the scroll b ...

Building a local database using the MVC framework concept

Can a locally stored database be developed using MVC framework principles in javascript and html5? Thank you Ravindran ...

Java: Issue with JLabel Text Alignment

At the bottom of my panel, I have a JLabel that provides text instructions to the user. When some of the text exceeded the screen width, I used tags to fix this issue. However, after implementing the code shown below, the text is no longer centered an ...

Trigger a notification based on the selected choice

Here is some sample HTML code: <div id="hiddenDiv" style="display: none;"> <h1 id="welcomehowareyou">How are you feeling today?</h1> <select name="mood" id="mood"> <option value="" disabled selected>How are you feeling?</o ...