css3 3d case summary
I recently got into Web animation, so I will record my learning process and share it with everyone. Let me share with you what I have done recently
1. Rotating puzzle
First look at the effect
The code mainly consists of HTML and CSS3, which should be said to be relatively simple.
The first is the HTML code:
<p> </p><p> </p><p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p> </p><p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p> </p><p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p> </p><p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p> </p><p></p> <p></p> <p></p> <p></p> <p></p> <p></p>
A 3-layer p HTML framework is used here, and the level is very clear.
The next focus is on the CSS code, how to use the features of CSS3 to achieve 3D and scrolling effects, so that it always looks 3D.
body{ background: red;}/*对于相机元素*/.camera{ perspective: 800px;/*这个属性是视距(景深),就是目测的距离*/ width: 500px; height: 300px; margin: auto; transform-style: preserve-3d;/*该属性规定如何在 3D 空间中呈现被嵌套的元素。preserve-3d子元素将保留其 3D 位置。*/}/*对于模块元素*/.kuai{ width: 100px; height: 300px; margin: 50px auto; float: left; transform-style: preserve-3d; position: relative; transition:transform 1s; margin-left: -1px;}/*对于模块的每个面元素*/.kuai:nth-of-type(2)>.mian{ background-position: -100px 0;}.kuai:nth-of-type(3)>.mian{ background-position: -200px 0;}.kuai:nth-of-type(4)>.mian{ background-position: -300px 0;}.kuai:nth-of-type(5)>.mian{ background-position: -400px 0;}.kuai:nth-of-type(6)>.mian{ background-position: -500px 0;}.mian{ width: 100px; height: 300px; position: absolute; font-size:100px; text-align: center; line-height: 300px; transform-style: preserve-3d; background-color: black; backface-visibility: hidden;}.mian:nth-of-type(1){ transform: translateZ(150px); background:url(../images/pic1.jpg) no-repeat; background-size: 500px 100%;}.mian:nth-of-type(2){ transform: translateZ(-150px) rotateX(180deg); background:url(../images/pic2.png) no-repeat; background-size: 500px 100%;}.mian:nth-of-type(3){ width: 300px; transform: rotateY(-90deg) translateZ(150px);/*3d中transform属性是关键的,它主要是靠旋转 移动 缩放来变形实现的*/}.mian:nth-of-type(4){ width: 300px; transform: rotateY(90deg) translateZ(-50px);}.mian:nth-of-type(5){ transform: rotateX(90deg) translateZ(150px); background:url(../images/pic3.jpg) no-repeat; background-size: 500px 100%;}.mian:nth-of-type(6){ transform: rotateX(-90deg) translateZ(150px); background:url(../images/pic4.jpg) no-repeat; background-size: 500px 100%;}
The last thing is js
window.onload=function() { var camera=document.getElementById('camera'); var kuais=camera.getElementsByClassName('kuai'); var chishu=0; var geshu=5; camera.onclick=function() { chishu++; for(var i=0;i<geshu><p>There is an attribute here that is not used for transform-origin. It is used to change the origin position of the element and does not need to be set. As shown in the figure <br><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/013/a1c4a0022d33fa110b8f01359cde5423-1.png?x-oss-process=image/resize,p_40" class="lazy" alt="人人都能读懂的css3 3d小demo " style="max-width:90%" style="max-width:90%" title="人人都能读懂的css3 3d小demo "><br>Similarly, it can also be set to: transform-origin:top right (the upper right corner is the origin), transform-origin:bottom right (the lower right corner is the origin), transform-origin:bottom left (the lower left corner is the origin) </p> <h1 id="Summary">Summary</h1> <h4 id="In-short-in-the-process-of-learning-CSS-I-saw-a-lot-of-new-features-and-learned-how-to-use-them-but-what-I-want-to-say-is-No-matter-how-we-learn-how-to-use-it-we-also-need-to-understand-why-each-line-of-code-produces-the-corresponding-effect-Especially-for-D-transform-we-need-to-fundamentally-understand-the-D-space-in-order-to-better-grasp-what-each-of-its-attribute-values-can-bring-come-effect">In short, in the process of learning CSS3, I saw a lot of new features and learned how to use them, but what I want to say is No matter how we learn how to use it, we also need to understand why each line of code produces the corresponding effect. Especially for 3D transform, we need to fundamentally understand the 3D space in order to better grasp what each of its attribute values can bring. come effect. </h4> <p>For more articles related to css3 3d small demo that everyone can understand, please pay attention to the PHP Chinese website! </p> <p><br></p></geshu>

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatilityandpowerincreatingsmoothCSSanimations.Keytricksinclude:1)Definingsmoothtransitionsbetweenstates,2)Animatingmultiplepropertiessimultaneously,3)Usingvendorprefixesforbrowsercompatibility,4)CombiningwithJavaScriptfo

CSSCountersareusedtomanageautomaticnumberinginwebdesigns.1)Theycanbeusedfortablesofcontents,listitems,andcustomnumbering.2)Advancedusesincludenestednumberingsystems.3)Challengesincludebrowsercompatibilityandperformanceissues.4)Creativeusesinvolvecust

Using scroll shadows, especially for mobile devices, is a subtle bit of UX that Chris has covered before. Geoff covered a newer approach that uses the animation-timeline property. Here’s yet another way.

Let’s run through a quick refresher. Image maps date all the way back to HTML 3.2, where, first, server-side maps and then client-side maps defined clickable regions over an image using map and area elements.

The State of Devs survey is now open to participation, and unlike previous surveys it covers everything except code: career, workplace, but also health, hobbies, and more.

CSS Grid is a powerful tool for creating complex, responsive web layouts. It simplifies design, improves accessibility, and offers more control than older methods.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools
