Struggling with a background problem that arises specifically when using transform: rotateY() - interestingly, it appears to be isolated to

Attempting to create a 3D Flip Card in CodePen has presented an issue. When hovering over the card, the content is intended to rotate along the Y axis. However, upon implementation in CodePen, the background of the card front becomes transparent, revealing the back's background instead.

The same code tested in Chrome and Firefox browsers functions correctly without any transparency issues.

Various adjustments have been made including using transform-style: preserve-3d; and backface-visibility: hidden;, but the problem persists.

Could this be a bug exclusive to CodePen, since it works fine on regular browsers?

My code:

:root {
  box-sizing: border-box;
  font-family: sans-serif;
}
*, *::before, *::after {
 box-sizing: inherit;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.card {
 width: 300px;
 height: 400px;
 transform-style: preserve-3d;
}
.card__content {
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 3s ease;
  position: relative;
 }

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

.card__front, .card__back {
  text-align: center;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 5em;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  border: 1px solid black;
 }

.card__front {
 background: red;
}

 .card__heading {
 transform: translateZ(2rem);
}
.card__desc {
 transform: translateZ(3rem);
}

.card__back {
 transform: rotateY(180deg);
 background: blue;
}
.card__body {
 max-width: 60%;
 transform: translateZ(4rem);
}
<div class="card">
 <div class="card__content">
   <div class="card__front">
     <p class="card__desc">
       This would be some text
     </p>
     <h1 class="card__heading">
       Your Heading
     </h1>
   </div>
   <div class="card__back">
     <p class="card__body">
       Lorem ipsum dolor sit amet consectetur adipisicing elit.
     </p>
   </div>
 </div>
</div>

Link to the CodePen: https://codepen.io/xutocode/pen/KKaNQqY?editors=1100 In the linked example, observe how the red background of the card's front transitions to blue before rotation. Is this a known bug within CodePen?

Answer №1

Issues have been reported with Safari and the backface-visibility property. It seems to require the webkit prefix to work properly in this browser. You can try the following CSS code which has been tested and proven to solve the problem on Safari:

.card__front, .card__back {
  text-align: center;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 5em;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -o-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  border: 1px solid black;
}

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

The format provided is not utilized by Datetimepicker

I've encountered an issue with the Date Time Picker provided by JQuery. Despite setting a specific format, it seems to be using its default date format which results in the following error appearing in the console: Uncaught TypeError: F.mask.replace i ...

Animating the scale of an element while also adjusting its border-radius using CSS

I'm currently working on an animation that involves scaling a box with a rounded border of 8px. The issue I'm facing is that the rounded angle looks strange when the box is expanded, and I'm trying to avoid changing the width in the keyframe ...

I need to adjust my navbar in Bootstrap 5 so that one <li> item floats to the left while the remaining items float to the right

Currently embarking on my inaugural html/css venture while utilizing bootstrap. I do have some previous html experience from using Blogger in the past. Issue I'm encountering is that when expanding my navbar, I aim to have the first li item (a button ...

What is the most effective way to transfer a value from the server to a React user interface and incorporate it into the styling of the user interface?

Currently, I am utilizing Python as the backend for my React frontend. The backend is passing in values such as 17 or 87, and I aim to use these values as a percentage on the scale that I am constructing. Currently, the scale starts in the center: https:/ ...

I am facing an issue where the text within my div element is not displaying as expected

My carousel is designed like this: I am having trouble displaying my labels correctly. This is an example of how I create one of my boxes: <div class="tl-box-wrapper"> <div class="tl-box"> <div class="tl-top"> <i class= ...

Looping through JSON data to dynamically generate DIV elements

Currently, I have in my possession a JSON array that contains various values. To convert this List to JSONArray, I employed the JSON-lib and some groovy classes. Along with the JSON array, I also have a JS file and a JSF for the front end. My task at hand ...

The javascript function "Scroll to the element" is not functioning properly on my website. Perhaps using JQuery will resolve the issue

I used this bootstrap template to create my website. Everything worked perfectly except for the "scroll to the element script". I kept encountering the following error: Uncaught Error: Syntax error, unrecognized expression: [href=#],[data-toggle],[data-tar ...

The issue of Chrome not updating when resizing the window in jQuery

I've encountered an issue while using jQuery to obtain the height of a specific element, as this measurement changes when someone resizes their browser window. Below is the code snippet I am currently using: $(function() { var wheight = $('. ...

"Incorporating melodic undertones into your website design

Looking to enhance my website with a feature that allows users to choose and play music of their liking directly on the site. I have a few questions regarding this: 1. Transition between pages: If a user selects a song like a.mp3 and then navigates to an ...

When I tried using the HTML 5 boilerplate extension in VS code, I received an error message indicating that it was not functioning properly

I've recently entered the realm of tech and decided to give VS Code a try. After downloading it, I installed several extensions, but unfortunately some of them aren't functioning properly. My primary issue is with the HTML5 boilerplate extension. ...

Tips for reducing word length in Bootstrap card text using Django and CSS

For my journal entries, I'm using Bootstrap's card component. It looks like this: View Journal List However, when I have a lot of text in the entry, the card stretches out too long. View Journal List with a Really Long Entry I want to show ju ...

Unusual actions regarding flexible CSS style sheet

There have been countless times when I have utilized a CSS technique that I discovered on my own. When I need a dynamic stylesheet that can be included in an HTML document, I use CSS files that are not actually CSS files, but PHP files instead. For example ...

When using the SASS @debug directive, it has the ability to display two distinct values for a single variable

Encountering an issue while compiling a scss file to css, the error message reads as follows: Error: src/scss/_custom.scss Error: Incompatible units: 'rem' and 'px'. To address this, I inserted @debug directives above the problematic ...

Demonstrate the smooth transition of background colors

I am attempting to add a subtle animation to the background-color in my navbar, as it currently appears suddenly. I want the transition to be smooth and gradual. Check out the JSFiddle demo here: https://jsfiddle.net/3f0czkpt/ The jQuery ...

Issue with phpMailer When Setting HTML Content

Recently, I encountered an issue while trying to send an image attachment and an HTML message using phpMailer. Despite my efforts, the page displayed an error indicating that it was not functioning properly. include 'PHPMailer-master/class.phpmailer. ...

Ways to conceal text while still allowing it to be read by a screen reader

I am looking for a way to have a text updated by an action without displaying it on the webpage, but still have it announced by screen readers. I tried using display: none and visibility: hidden, however, these properties seem to not be accessible by scr ...

The functionality of uploading both images and videos in one submission is not reliable when it comes to file size restrictions

I've been struggling for a long time trying to figure out how to solve my issue. I need to upload an image and a video file using the submit function, each with different size requirements - the image should be around 1MB and the video file around 10M ...

Ensure that the first column remains stationary while the remaining columns are condensed within the table

I am looking for a solution to display the first column of a table on one row while allowing the other columns to adjust and fit into the remaining space. My attempt involved setting a fixed width of 320 for phone size. To view my plunker, click here: ht ...

Add additional text using the ::after pseudo-element exclusively for a particular class

Here is the HTML code snippet I am currently working with: <style> p::after { content: "%"; } </style> <div class="counter-box"> <p data-value="185">100</p> </div> At present, my CSS applies text injection to ...

Strange CSS/browser storage glitch

UPDATE: JUST REALIZED THIS ISSUE IS ONLY OCCURRING ON FIREFOX, NOT CHROME ANOTHER UPDATE: Oddly enough, this problem only occurs locally. When I push it to GitHub, everything works fine. So strange. I suppose that means it's not a major issue. On my ...