CSS3 creates 3D cube loading effects

CSS3 creates 3D cube loading effects

Brief Description

This is a CSS3 cool 3D cube preloading effect. This special effect uses simple HTML elements and CSS3 codes to construct an animation effect of several cubes moving continuously, which is suitable for page loading effects.

Code Analysis

Import the following files into your HTML file.

<link rel="stylesheet" type="text/css" href="css/bootstrap-grid.min.css" />

HTML Structure

<div class="demo" style="min-height:350px;">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="loader">
<div class="box">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</div>
<div class="box">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</div>
<div class="box">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</div>
<div class="box">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</div>
</div>
</div>
</div>
</div>
</div>

CSS Styles

.loader{
                    --size: 32px;
                    --duration: 800ms;
                    width: 96px;
                    height: 64px;
                    margin: 50px auto;
                    transform-style: preserve-3d;
                    transform-origin: 50% 50%;
                    transform: rotateX(60deg) rotateZ(45deg) rotateY(0deg) translateZ(0px);
                    position: relative;
                }
                .loader .box{
                    width: 32px;
                    height: 32px;
                    transform-style: preserve-3d;
                    position: absolute;
                    top: 0;
                    left: 0;
                }
                .loader .box:nth-child(1){
                    transform: translate(100%, 0);
                    animation: box1 800ms linear infinite;
                }
                .loader .box:nth-child(2){
                    transform: translate(0, 100%);
                    animation: box2 800ms linear infinite;
                }
                .loader .box:nth-child(3){
                    transform: translate(100%, 100%);
                    animation: box3 800ms linear infinite;
                }
                .loader .box:nth-child(4){
                    transform: translate(200%, 0);
                    animation: box4 800ms linear infinite;
                }
                .loader .box > div{
                    --translateZ: calc(var(--size) / 2);
                    --rotateY: 0deg;
                    --rotateX: 0deg;
                    background: #5c8df6;
                    width: 100%;
                    height: 100%;
                    transform: rotateY(var(--rotateY)) rotateX(var(--rotateX)) translateZ(var(--translateZ));
                    position: absolute;
                    top:auto;
                    right: auto;
                    bottom: auto;
                    left: auto;
                }
                .loader .box > div:nth-child(1){
                    top: 0;
                    left: 0;
                }
                .loader .box > div:nth-child(2){
                    background: #145af2;
                    right: 0;
                    --rotateY: 90deg;
                }
                .loader .box > div:nth-child(3){
                    background: #447cf5;
                    --rotateX: -90deg;
                }
                .loader .box > div:nth-child(4){
                    background: #dbe3f4;
                    top: 0;
                    left: 0;
                    --translateZ: calc(var(--size) * 3 * -1);
                }
                @keyframes box1{
                    0%, 50%{ transform: translate(100%, 0); }
                    100%{ transform: translate(200%, 0); }
                }
                @keyframes box2{
                    0%{ transform: translate(0, 100%); }
                    50%{ transform: translate(0, 0); }
                    100%{ transform: translate(100%, 0); }
                }
                @keyframes box3{
                    0%, 50%{ transform: translate(100%, 100%); }
                    100%{ transform: translate(0, 100%); }
                }
                @keyframes box4{
                    0%{ transform: translate(200%, 0); }
                    50%{ transform: translate(200%, 100%); }
                    100%{ transform: translate(100%, 100%); }
                }

The above is the details of how to use CSS3 to create 3D cube loading effects. For more information about CSS3 loading effects, please pay attention to other related articles on 123WORDPRESS.COM!

<<:  CSS to change the size (width, height) of the image when the mouse passes over the image hyperlink

>>:  About the layout method of content overflow in table

Recommend

Vue2 implements provide inject to deliver responsiveness

1. Conventional writing in vue2 // The parent com...

How to install redis in Docke

1. Search for redis image docker search redis 2. ...

Examples of using html unordered list tags and ordered list tags

1. Upper and lower list tags: <dl>..</dl...

Thumbnail hover effect implemented with CSS3

Achieve resultsImplementation Code html <heade...

How to use http and WebSocket in CocosCreator

Table of contents 1. HttpGET 2. HTTP POST WebSock...

CentOS7 firewall and port related commands introduction

Table of contents 1. Check the current status of ...

jQuery implements accordion effects

This article shares the specific code of jQuery t...

Learn one minute a day to use Git server to view debug branches and fix them

Debug branch During the normal development of a p...

MySQL 8.0.17 installation and usage tutorial diagram

Written in front In the past and in the current p...

JavaScript timer to achieve limited time flash sale function

This article shares the specific code of JavaScri...

Centos7 implements sample code for restoring data based on MySQL logs

Introduction Binlog logs, that is, binary log fil...

Cross-domain issues in front-end and back-end separation of Vue+SpringBoot

In the front-end and back-end separation developm...

Example of implementing load balancing with Nginx+SpringBoot

Introduction to Load Balancing Before introducing...

Introduction to the properties of B-Tree

B-tree is a common data structure. Along with him...

Correct use of Vue function anti-shake and throttling

Preface 1. Debounce: After a high-frequency event...