This is a simple HTML and CSS code snippet that creates a 3D rotating tube with animated text on its faces. The tube is displayed in a webpage and the text on each face of the tubr changes dynamically, creating a visually engaging effect.
The code uses HTML and CSS to create the 3D rotating cube effect:
The HTML structure is relatively simple:
- The
<!DOCTYPE html>
declaration specifies the document type and language. - The
<head>
section includes metadata and references to external resources, such as fonts and a CSS file (style.css
). - The
<body>
section contains a<div>
element with the classcontainer
. Inside this container, there is another<div>
with the classbox
, which represents the 3D cube. Within thebox
, there are multiple<span>
elements, each containing text to be displayed on the cube's faces.
The CSS in the style.css
file is responsible for the 3D rotating cube effect and the animated text:
- Various font families are imported from Google Fonts to be used in the text.
- Global reset rules ensure consistent styling across different browsers.
- The
body
element is styled to create a full-page display and center the cube. - The
.container
class styles are used to center the.box
element within the container. - The
.box
class is where the 3D cube effect is applied. It uses thetransform-style
property to enable 3D transformations and applies an animation calledanimate
to achieve the rotation effect. - The
.box span
class styles each face of the cube. Thebackground
property adds a gradient background, and thetransform
property rotates each face along the X-axis. - The
.box span i
styles the<i>
elements (italic text) within the spans, allowing for additional text formatting. - The
@keyframes animate
rule defines the animation sequence that rotates the cube along the X-axis and Y-axis, giving the illusion of a rotating cube.
- Copy the HTML code and save it in an HTML file.
- Copy the CSS code and save it in a file named
style.css
in the same directory as the HTML file. - Open the HTML file in a web browser to see the 3D rotating cube with animated text.
Feel free to customize the text, fonts, colors, and animation properties to create your own unique 3D cube effect!
This code was inspired by a design created by Aarzoo on CodePen.
This code is released under the MIT License.
![Screenshot 2023-08-30 182954](https://private-user-images.githubusercontent.com/59678435/264350890-bacfa9cf-fe25-4707-b5e7-d8cb38361144.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5ODE4NTIsIm5iZiI6MTczODk4MTU1MiwicGF0aCI6Ii81OTY3ODQzNS8yNjQzNTA4OTAtYmFjZmE5Y2YtZmUyNS00NzA3LWI1ZTctZDhjYjM4MzYxMTQ0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDAyMjU1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYzM2Q4MWI3NjQ0MmRkOGIwYjI2OWFiNjNhYjViNWNjNjE2ODRiNzgwMGUxZWFjZWRlM2QyOTI3OThmNTI5ZjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Hhf-_yFJyoMSipN0EiYfVNmWAamDwa7qP4kGsjpEgxw)