What is preventing me from clicking on the left side of the link on this CSS flip card while using Chrome browser?

When attempting to click the left side of the link on the back of this flip card in Chrome, it does not respond. However, hovering over the right side allows interaction with the link:

/* Vendor prefixed by https://autoprefixer.github.io */

.card {
  -webkit-perspective: 1000px;
  perspective: 1000px;
  display: inline-block;
}

.card .card-inner {
  position: relative;
  transition: -webkit-transform 0.6s;
  transition: transform 0.6s;
  transition: transform 0.6s, -webkit-transform 0.6s;
  transform-style: preserve-3d;
  will-change: transform;
}

.card:hover .card-inner {
  transform: rotateY(180deg);
}

.card .card-back {
  background: steelblue;
}
<div class="card">
  <div class="card-inner>
    <img src="https://via.placeholder.com/400x500?text=%20" alt="" />

    <div class="card-face card-front">
      <div class="card-face-inner">
        <div class="card-face-content">
          Front
        </div>
      </div>
    </div>

    <div class="card-face card-back">
      <div class="card-face-inner">
        <div class="card-face-content">
          <a href="#foo">Back</a>
        </div>
      </div>
    </div>
  </div>
</div>

How can I ensure the entire link is clickable? It seems like the issue might be related to backface-visibility. While researching, I found a similar question on StackOverflow (link here), but based on my code snippet, it looks like the solution is already implemented with these lines:

.card .card-inner {
    ...
    transform-style: preserve-3d;
}

Answer №1

Chrome's small precision errors make 180 degrees not exactly half a turn.

Even if unseen, the left side of the element lies beneath the front side.

To solve this issue, elevate your element slightly in the Z direction:

/* Code with autoprefixer applied */ 

.card {
  -webkit-perspective: 1000px;
  perspective: 1000px;
  display: inline-block;
}

.card .card-inner {
  position: relative;
  -webkit-transition: -webkit-transform 0.6s;
  transition: -webkit-transform 0.6s;
  -o-transition: transform 0.6s;
  transform-style: preserve-3d;
  will-change: transform;
}

.card .card-inner .card-face {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  backface-visibility: hidden;
}

.card .card-inner .card-face.card-back {
  transform: rotateY( 180deg) translateZ(1px);   /* Updated */
}

.card .card-inner .card-face .card-face-inner .card-face-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Arial, sans-serif;
  font-size: 22px;
}

.card:hover .card-inner {
  transform: rotateY( 180deg);
}

.card .card-back {
  background: steelblue;
}
<div class="card">
  <div class="card-inner>
    <img src="https://via.placeholder.com/400x500?text=%20" alt="" />

    <div class="card-face card-front">
      <div class="card-face-inner>
        <div class="card-face-content">
          Front
        </div>
      </div>
    </div>

    <div class="card-face card-back">
      <div class="card-face-inner>
        <div class="card-face-content">
          <a href="#foo">Back</a>
        </div>
      </div>
    </div>
  </div>
</div>

Answer №2

It's unclear why this issue is happening, but it seems to be a bug since it works fine on Firefox. The workaround of adding pointer-events: none; to .card-inner and pointer-events: auto to .card-face miraculously resolves the problem.

/* Styles with autoprefixer applied */

.card {
  -webkit-perspective: 1000px;
  perspective: 1000px;
  display: inline-block;
}

.card .card-inner {
  position: relative;
  -webkit-transition: -webkit-transform 0.6s;
  transition: -webkit-transform 0.6s;
  -o-transition: transform 0.6s;
  transition: transform 0.6s;
  transition: transform 0.6s, -webkit-transform 0.6s;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  will-change: transform;
  pointer-events: none;
}

.card .card-inner .card-face {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  pointer-events: auto;
}

.card .card-inner .card-face.card-back {
  -webkit-transform: rotateY( 180deg);
  transform: rotateY( 180deg);
}

.card .card-inner .card-face .card-face-inner .card-face-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-family: Arial, sans-serif;
  font-size: 22px;
}

.card:hover .card-inner {
  -webkit-transform: rotateY( 180deg);
  transform: rotateY( 180deg);
}

.card .card-back {
  background: steelblue;
}
<div class="card">
  <div class="card-inner">
    <img src="https://via.placeholder.com/400x500?text=%20" alt="" />

    <div class="card-face card-front">
      <div class="card-face-inner">
        <div class="card-face-content">
          Front
        </div>
      </div>
    </div>

    <div class="card-face card-back">
      <div class="card-face-inner">
        <div class="card-face-content">
          <a href="#foo">Back</a>
        </div>
      </div>
    </div>
  </div>
</div>

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

Achieving Full Row Height in Twitter Bootstrap using CSS Grid

Before jumping to conclusions and marking this question as a duplicate, I want to clarify that I have already explored all suggestions provided on Stack Overflow, including the use of display: table. Unfortunately, none of them seem to work smoothly with B ...

Anticipating the arrival of the requested data while utilizing Ajax sending

Greetings, I'm currently utilizing JavaScript to send a request and receive a response from the server. xxmlhttp.open("GET","ajax_info.txt",true); xmlhttp.send(); myotherMethod(); I am looking for a way to ensure that the next set of instructions ar ...

Progressively increasing the time by 15 seconds during each iteration of the CSS @each loop

I recently made changes to a CSS script that involves the repetition of an animation task. Rather than repeating a segment of code 30 times, I decided to streamline it using a loop. Now, there are 30 <div></div> segments and each one undergoes ...

Sticky positioning and visible overflow restrictions

When position sticky is used within a container with overflow:hidden, it does not work as expected. However, the overflow hidden property is necessary in this case. <div class="lg:col-start-7 lg:col-end-13" style="overflow:hidden"&g ...

Troubleshooting the Problem with CSS Margin in HTML Footer

I'm encountering an issue with the footer on my website. The margin: auto; command doesn't seem to be working for the list items in the footer. I want the items in the footer to occupy one-third of the width, but no matter where I place the marg ...

"Embrace the power of Bootstrap 3 with a cutting-edge logo,

Looking to design a layout that features a logo on the left and a slogan pane with the navigation bar below it on the right. Check out image #1 for reference. As the screen narrows, the plan is to have the navigation pane move below the logo and slogan. T ...

CSS inset box-shadow creates a gap between collapsed borders

I need help with a strange issue I'm facing. I have a table where border-collapse is set to collapse, and there's an unusual gap between the box-shadow inset and the border. The size of this gap increases as the border width gets larger. How can ...

Is there a way for me to superimpose text onto an image in this instance?

I am attempting to place a "Text overlay goes here" over the profilepic.jpg image below. I believe there may be an issue with my CSS code. My approach was to create a new div class named overlay and embed that line within the imgcontainer class. Can some ...

The mouse scurries away once the div height has been adjusted

How can I make the height of #header change when hovering over #hoverme, and then revert back to its original height when the mouse leaves #hoverme? If anyone knows a solution, please check out my jsfiddle as it's not working as I intended. Here is ...

Having trouble getting the timer function to execute upon page load in JavaScript

My goal is to have my basic timer function activate when the page loads. However, I'm encountering issues with it not working as intended. I suspect there may be an error in the if else loop, possibly here: setTimeout(function(tag, sec), 1000);. How c ...

Is there a way to process the output of phantom.js in PHP efficiently?

I have successfully retrieved output from a phantom.js request via the command line and it meets my expectations. Now, I am interested in invoking phantom.js from a php script and then analyzing the output for specific content. My phantom.js script appear ...

How can I prevent a CSS class from being rendered in a specific view within MVC?

My knowledge of CSS is quite limited and I am fairly new to it. In my MVC application, I am using a theme that relies on Bootstrap. In the _layout view of my application, I have the following code: <div class="container body-content"> @Html.Par ...

Retrieving and storing information from a form without the need to submit it

I have been given the task of creating a load/save feature for a complex form. The goal is to allow users to save their progress and resume working on it at a later time. After much consideration, I have decided to implement server-side storage by saving ...

The issue of CSS not functioning properly across various page sizes

I have created my toolbar: <header className='toolbar'> <nav className='toolbar_navigation'> ///hamburger: <SideDrawer drawerClicked = {props.drawerClicked} /> ///LOGO ...

Having issues getting the single div to refresh with `.#div.load(scriptpage.php)` command

I've been attempting to update the content of a specific div (in-game chat) every X seconds or minutes using this simple code. The issue I'm facing is that the content never refreshes or loads the new page. I've searched through various cod ...

Adjust the width of the table by utilizing the border-collapse property set to collapse

I am completely baffled by this situation. Whenever I adjust the border-width of a table (either dynamically with JavaScript or in Chrome Dev Tools) where border-collapse: collapse; is set, transitioning from a border width of 1px (#1) to a larger value (# ...

Establish a predetermined selection for a drop-down menu

How can I set a default value for a dynamically filled dropdown menu featuring all 12 months in KnockoutJS? I want the default value to be the current month. This is how I am populating the dropdown with information: self.setMonthData = (data ...

Define CSS styles based on the content of a specific cell within a table

Is there a way to target a <td> in CSS based on its content value? <table> <tr> <td>Name</td> <td>John</td> <tr> </table> For instance, how can I apply the color:bl ...

The issue with jspdf is that it is failing to generate PDF documents of

I'm currently developing a resume builder app using ReactJS. One of the functionalities I'm working on is enabling users to download their resumes as PDFs. However, I've encountered an issue with the generated PDFs when using jsPDF. The down ...

Is the `document.documentElement` consistently defined and always representing the HTML element?

I am looking to make changes to the <html> element using a script within the <head> section of an HTML page. My goal is to only access and modify the <html> element itself, without affecting any of its children. Should I wait for the DOM ...