The animated 3D cube is specifically compatible with Firefox

After working on a 3D animated cube that rotates infinitely in two angles, I encountered some browser compatibility issues. The cube can be found on the home page of our new company website (next to the Software title when scrolling down) at test website. It works fine in Firefox, but in Google Chrome and Opera it doesn't display correctly. When inspecting the element and adjusting certain attributes in the styles menu, the cube may appear with gaps between its faces. In Microsoft Edge, the cube displays but does not rotate. As for Safari, I haven't tested it as I am using Windows.

Moreover, the images on the cube faces are displayed properly only in Firefox. Other browsers seem to zoom in on the images, showing only a fraction of the seismic layers present.

In an attempt to troubleshoot, I created a demo on JSFiddle using Google Chrome. Setting the class "col" to 100vh did not work for me as it resulted in a large empty space on our homepage.

I am seeking assistance on how to ensure this 3D rotating cube functions seamlessly across all browsers. Any guidance or suggestions would be greatly appreciated. Thank you in advance!

* {
    margin: 0;
}
html, body {
    height: 100%;
}
body {
    perspective: 25em;
}
.row {
    display: flex;
}
.row::after {
    display: block;
    content: '';
    clear: both;
}
.col {
    position: relative;
    flex: 1;
}
[class*='cube'] {
    position: absolute;
}
.cube {
    top: 50%;
    left: 50%;
    font-size: 8vmin;
    transform-style: preserve-3d;
    animation: cube 8s linear infinite;
}
.cube-face {
    margin: -2em;
    width: 4em;
    height: 4em;
    backface-visibility: hidden;
}
.cube-face:nth-child(1) {
    transform: translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-1.jpg) center/contain no-repeat fixed;
}
.cube-face:nth-child(2) {
    transform: rotateY(90deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-2.jpg) center/contain no-repeat fixed;
}
.cube-face:nth-child(3) {
    transform: rotateY(180deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-3.jpg) center/contain no-repeat fixed;
}
.cube-face:nth-child(4) {
    transform: rotateY(270deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-4.jpg) center/contain no-repeat fixed;
}
.cube-face:nth-child(5) {
    transform: rotateX(90deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-5.jpg) center/contain no-repeat fixed;
}
.cube-face:nth-child(6) {
    transform: rotateX(-90deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-6.jpg) center/contain no-repeat fixed;
}
@keyframes cube {
to {
    transform: rotate3d(1, 1, 1, 1turn) rotate3d(1, -1, 1, 1turn);
    }
}
<div class="row">
    <div class="col">
        <div class="cube">
            <div class="cube-face"></div>
            <div class="cube-face"></div>
            <div class="cube-face"></div>
            <div class="cube-face"></div>
            <div class="cube-face"></div>
            <div class="cube-face"></div>
        </div>
    </div>
</div>

Answer №1

It seems like I was able to resolve the issue in Google Chrome and Opera by removing the fixed position on the cube faces. However, the problem still persists in Microsoft Edge.

* {
    margin: 0;
}
body {
    height: 100vh;
}
[class*=cube] {
    position: absolute;
}
.cube {
    top: 50%;
    left: 50%;
    font-size: 8vmin;
    transform-style: preserve-3d;
    animation: cube 8s linear infinite;
}
.cube-face {
    margin: -2em;
    width: 4em;
    height: 4em;
    backface-visibility: hidden;
}
.cube-face:nth-child(1) {
    transform: translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-1.jpg) center/contain no-repeat;
}
.cube-face:nth-child(2) {
    transform: rotateY(90deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-2.jpg) center/contain no-repeat;
}
.cube-face:nth-child(3) {
    transform: rotateY(180deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-3.jpg) center/contain no-repeat;
}
.cube-face:nth-child(4) {
    transform: rotateY(270deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-4.jpg) center/contain no-repeat;
}
.cube-face:nth-child(5) {
    transform: rotateX(90deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-5.jpg) center/contain no-repeat;
}
.cube-face:nth-child(6) {
    transform: rotateX(-90deg) translateZ(2em);
    background: url(http://test.dgbes.com/images/cube-face-6.jpg) center/contain no-repeat;
}
@keyframes cube {
to {
    transform: rotate3d(1, 1, 1, 1turn) rotate3d(1, -1, 1, 1turn);
    }
}
<div class="cube">
    <div class="cube-face"></div>
    <div class="cube-face"></div>
    <div class="cube-face"></div>
    <div class="cube-face"></div>
    <div class="cube-face"></div>
    <div class="cube-face"></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

Different methods for updating a label with a count from a MySQL database using Ajax

Ajax seems to be the most suitable method for this task. Below is a PHP file that provides a count: <?php include('globals.php'); $query = mysqli_query($con, "SELECT COUNT(*) as total FROM solicitacoes WHERE visualizada = 0"); $r ...

Experiencing difficulty aligning the Material UI grid to float on the right side

I'm currently in the learning phase of material-ui and encountering an issue with floating the grid content to the right side. Despite trying alignItems="flex-start" justify="flex-end" direction="row" in the container grid, as well as using the css p ...

Simple Steps for Dynamically Adjusting Table Cells without Disturbing Existing Data

Is there a way to make a table automatically arrange cells in rows of two, adjusting as necessary when adding or removing cells (with one cell in the last row if there is an odd number of total cells)? For example: <table> <tr> <td>o ...

What happens to the content within a <textarea> element if it is not enclosed between the opening and closing tags?

Here's a puzzling situation - I've entered the word Hello. into a <textarea>, and while I can see it on my screen, it doesn't show up between the opening and closing <textarea> tags. It may seem like a simple issue, but I'v ...

Can 'fr' units be used in the `calc()` function of CSS?

In this particular scenario, the query arises whether the CSS calc() function extends its support to the fr unit as presented in the below example? .sample-grid { --main-fr: 60fr; grid-template-columns: var(--main-fr) 1rem calc(100 - var(--main-fr ...

Various Overlay Shapes in Bootstrap Using CSS

So I'm in the process of styling my landing page with CSS based on a design I have in Figma. The page is using Bootstrap 5 as its framework, though I'm not sure if that detail matters in this case. I believe it's definitely doable, but I&apo ...

What is the best method for efficiently wrapping contents within a div container?

On the website cjshayward.com/index_new.html, there is a div wrapped around the content of the body, which is approximately 1000 pixels wide. In Chrome and Firefox, the wrapper works perfectly for the top section of about 100 pixels. Further down the page, ...

There is a significant spacing issue between the header and main category when viewed on a mobile device

Experiencing issues with element distances on different screen sizes? While the website looks fine on normal screens, there's a noticeable gap between the header and main sections on mobile devices. See below for the provided HTML and CSS code. ...

Website rendering tearing problem observed in Webkit on iOS browsers

I'm encountering a strange issue with my website's rendering specifically on iOS webview browsers such as Safari, Chrome, and Firefox. This problem only seems to occur on iOS devices and is not replicable on PC, Mac, or Android devices. Initiall ...

`ASP.NET utilized for displaying several pictures on a website`

My goal is to retrieve images from a database and showcase them on a webpage. I am looking to incorporate a "show more images" button in case there are too many images to display at once. Additionally, I would like for the additional images to load autom ...

Deleting a button from a list item or array in Angular 12

Having some trouble removing a list item with the click button, I've tried a few options but nothing seems to be working. Can anyone offer assistance? I need to remove a list item from my users array when clicked. Below is the Typescript code and cor ...

Creating a clickable pagination box involves utilizing CSS to style the entire <li> element with the necessary properties

Is there a way to make the entire LI box clickable for the pagination box? The HTML and CSS parts are functioning correctly, as I am able to click the link with the page number to navigate to the next page. However, the issue arises when trying to click t ...

Incorporating a clickable link within a variable in an HTML table

I'm attempting to insert a hyperlink into a variable within a table row. Here is my current code: echo "<td>"<a target='_blank' href="'http://alpha.bug.corp.com/show_bug.cgi?id=$ticket_id'"> $ticket_id </a>"</ ...

At times, Firefox may fail to fully showcase an image in fullscreen mode

Currently, my goal is to showcase an image in fullscreen mode using JavaScript. (Refer to the Fullscreen API - https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API) JavaScript snippet: var requestFullscreen = function(el) { if(el.requestFullsc ...

Transform the inline style attributes found in the HTML code into CSS styling

After creating a webpage using Bootstrap Studio, I realized that all the style attributes are inline and I want to move them to a separate CSS file. However, I am facing difficulty in doing so as when I add an image using 'background-image:url('i ...

Snug enclosure surrounding an image

I'm currently working on creating a chat application and I need the chat bubbles to snugly wrap around their contents. It's working fine for text, but when an image is included in the bubble, it creates some issues. Below is the HTML code that I ...

Function activation in Element requires a double click to initiate

I've encountered an issue with a web element I'm working on where the click function only triggers after the first click, rendering the initial click ineffective. Here's the code snippet in question: HTML: <div> <a href="#0" cla ...

Ensure that the initial section of the page spans the full height of the browser, while all subsequent sections have a

I have a website composed of various blocks with different heights, all extending to full width. My goal is to make the first block the full height and width of the browser window, while keeping the other blocks at a set height as seen on this site: After ...

Extracting Section Titles from INI using PHP

I've spent all night trying to perfect this code with no luck. I'm not even sure what to search for at this point. Here's the situation: I'm using PHP to parse .ini files into an HTML table. This is the code in my html file: <?php ...

What is the best way to apply a CSS class to a div element without affecting its child elements using JavaScript?

Currently, I am using JavaScript to add and remove a CSS class through a click event. Within my div structure, I have multiple similar divs. While I can successfully add and remove the class from my main div, I am facing an issue where the class is also ap ...