Safari browser problem with CSS transformation

Encountering an issue on iOS devices While implementing a rotating card using the code below, everything works smoothly on various devices except for Safari browser. There seems to be a problem with both the icon and the card itself. The complication arises when I set the transform style as 'preserve-3d', causing issues with the icon. However, I prefer it to remain in 2D. Why does this occur specifically in Safari browser and how can I rectify it? Your assistance is much appreciated.

document.querySelector(".card").addEventListener("click", function() {
  this.classList.toggle("clicked");
});
.card {
  height: 500px;
  width: 300px;
  position: relative;
  background-color: antiquewhite;
  transform-style: flat;
}

.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  backface-visibility: hidden;
  width: 80%;
  height: 80%;
  transform: translate(-50%, -50%);
  transition: transform 1s;
}

.back {
  transform: translate(-50%, -50%) rotateY(180deg);
  background-color: purple;
}

.front {
  background-color: yellowgreen;
}

.card.clicked .front {
  transform: translate(-50%, -50%) rotateY(-180deg);
}

.card.clicked .back {
  transform: translate(-50%, -50%) rotate(0);
}

.icon {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;  
  height: 50px;
  background-color: olive;
  border-radius: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
<div class="card">
  <div class="front panel"></div>
  <div class="back panel"></div>
  <div class="icon">CLICK</div>
</div>

Answer №1

The reason it's not functioning properly is due to the absence of the css-prefix required for this particular css attribute on Safari - specifically, the webkit-prefix.

-webkit-backface-visibility: hidden; /* Implementation for Safari */
backface-visibility: hidden;

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

Steps for designing image animations with fade in and fade out effects

I have a task to enhance the current code provided below, which currently works with only two images. HTML: <div id="cf"> <img class="bottom" src="<?php bloginfo('template_directory') ?>/assets/img/image1" /> <img class ...

What is the best way to align the progress bar near the element that initiated the task?

I am currently working on a dynamic website with jQuery, utilizing AJAX operations extensively. Whenever an AJAX operation is initiated, a progress bar is displayed in the center of the webpage. However, I am facing an issue where visitors find it cumbers ...

How to enhance the animation of the Material-UI right side persistent drawer

I am currently working on a sophisticated application that includes several drawers. Specifically, I am encountering an issue with the animations of the right side drawer. While the drawers animate correctly, the parent divs do not seem to follow suit. Eve ...

Disabling Hover effect on a particular element

Is there a way to eliminate the hover effect on my 'h3' tag (lighter grey hover effect), while keeping it as a link inside my 'a' tag? .speakers a { color: var(--clr-grey); } .speakers a:hover { color: var(--clr-lgrey); } &l ...

What is the best way to convert a string from a csv file into an integer using Python?

I'm currently working on a code that involves processing data obtained from this source () and organizing it into a CSV file. My goal is to create a program that calculates the BMI of each player, then identifies them as obese if their BMI exceeds 30 ...

Troubleshooting: Custom checkbox using CSS ::before does not display properly on Firefox and Edge browsers

Encountering a frustrating CSS challenge while working on a project that needs to be compatible across various browsers. Specifically, I'm having issues with custom styling for checkboxes. Despite following recommendations to use a ::before pseudo-ele ...

What is the best way to center text within a div that is wider than 100%?

On my webpage, I have a header set to 100% width and text positioned on the banner. However, when zooming in or out, the text's position changes. How can I ensure that the text stays in place regardless of zoom level? Example: jsfiddle.net/5ASJv/ HT ...

Outlook's limited width is causing images to exceed the boundaries of the HTML email

I have a collection of images that display perfectly in Gmail, but when viewed in Outlook, all five images appear within a single <tr> and cause the table width to expand. My desired layout is to have the first four images centered on the first line ...

What is the best way to emphasize the selected color?

I am having trouble with setting the focus and active properties for an input element. Even after selecting a color, the highlight does not appear. However, the hover property is working fine. Here is the code I have used to implement the highlight proper ...

having difficulty configuring gwt-button's corners to be rounded

Hey there, I'm having an issue with a button in my GUI that I created using GWT. I'm trying to round the corners of the button, but using border-radius doesn't seem to have any effect on its appearance. The style sheet I'm using is "co ...

Interactive Features in Vue Component

In my Vue Component, I have a prop named src that is bound to a :style attribute like this: <template> <section :class="color" class="hero" :style="{ backgroundImage: src && 'url(' + src + ')' }"> <slot> ...

Personalize the file button for uploading images

I have a button to upload image files and I want to customize it to allow for uploading more than one image file. What is the logic to achieve this? <input type="file" />, which renders a choose button with text that says `no files chosen` in the sa ...

Strikeout list on click of a mouse

Is there a way to apply strikethrough formatting to text with just a mouse click? The CSS for lists is beyond the form field margin. I've tried multiple methods without success. No matter how many times I change the code, I can't seem to get it r ...

Adding a CSS class to a link in Symfony 2 KNP Menu

I am currently utilizing the KnpMenuBundle for Symfony2, but I am facing an issue where I cannot find a way to add a CSS class to the generated links within the menu. I attempted to set the class using the child attribute, but unfortunately, it gets appli ...

Utilizing Multiple Selectors for Enhanced Selenium Testing

I am looking to test a webpage with a responsive layout where certain elements, like the menu, may vary based on resolution. How can I identify and target these elements using the same test classes? I am considering using How.CSS, using = "a.normal-link, ...

Moving items in a leftward direction

I am trying to create a CSS animation that makes multiple objects slide from right to left. The height of these objects should be random and the speed of the animation should also vary randomly. While I have successfully achieved this using JavaScript, I a ...

The act of selecting a parent element appears to trigger the selection of its child elements as well

I am attempting to create an accordion using Vanilla JavaScript, but I have encountered an issue. When there is a child div element inside the header of the accordion, it does not seem to work and I'm unsure why. However, if there is no child div elem ...

Enhanced Button Dropdown Function

I have the following HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Expanding Dropdown Menu</tit ...

Embracing right-to-left (RTL) languages

I am looking to create a website that can support both left-to-right (LTR) and right-to-left (RTL) languages seamlessly. My goal is to have the text direction switch automatically to RTL if the content is in an RTL language. Additionally, I want the input ...

Generate a vertical line that spans the entire length of the webpage in a vertical direction

Looking for a way to add vertical borders that span the entire webpage to some text? Check out this HTML snippet: <div id="vLine"> <h1>text</h1> </div> Here's the accompanying CSS: #vLine { height: 100%; width: 5 ...