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>

In a perfect world, our projects would have unlimited resources and time. Our teams would begin coding with well thought out and highly refined UX designs.

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons

SVG has its own set of elements, attributes and properties to the extent that inline SVG code can get long and complex. By leveraging CSS and some of the forthcoming features of the SVG 2 specification, we can reduce that code for cleaner markup.

You might not know this, but JavaScript has stealthily accumulated quite a number of observers in recent times, and Intersection Observer is a part of that

We may not need to throw out all CSS animations. Remember, it’s prefers-reduced-motion, not prefers-no-motion.

PWA (Progressive Web Apps) have been with us for some time now. Yet, each time I try explaining it to clients, the same question pops up: "Will my users be

It's extremely surprising to me that HTML has never had any way to include other HTML files within it. Nor does there seem to be anything on the horizon that

There are a lot of different ways to use SVG. Depending on which way, the tactic for recoloring that SVG in different states or conditions — :hover,


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

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool