In this article we will make a 3D Image Slider. We will use perspective, transform and transition properties of CSS3 to make the 3D Image Slider. We will also discuss making a nested circle using a div and CSS3.
The following image is the result. When we click on the circles we can see the 3D Image Slider Effect or we can use SetInterval() in JavaScript to see the continuously moving image slider. For tips you can refer to my previous blog:
http://www.c-sharpcorner.com/Blogs/46552/image-slider-using-jquery.aspx
Now we will discuss the code.
We are using 4 Images placed in 3D space that rotates on circle click. It looks like a rotating cube.
The following properties are responsible for 3D image slider.
I had already covered transform and perspective in the article:
http://www.c-sharpcorner.com/UploadFile/c325de/3d-rotation-of-element-using-css3/
We can refer to it for a flip effect of two elements.
1. perspective: perspective provides 3D space for children elements. It is a distance between the Z plane and the user.
2. perspective-origin: It is the vanishing point for 3D space provided by the perspective.
Note: Both the preceding properties are applied to the parent element.
3. transform-style: It is used to place children elements in 3D space. It can have the following two values.
- preserve-3d: It places elements in 3D space.
- flat: It is like a default HTML element.
4.transform-origin: It allows changing the point of origin of a transform.
5. transform: It changes shape, size and position without disrupting the normal document flow. CSS transforms are rooted in linear algebra and geometry.
Now we discuss circles that are created with two nested divs using CSS3.
- border-radius: 50%: It is responsible for making a circle shaped div.
- top: 24% and left: 24%: It is responsible for placing a child div exactly in the center.
In JavaScript we are only changing the CSS property transform: rotateY();.
Code