Day # 35: Flip Book
I consider myself to be an avid reader. I like to read all the time about all types of subjects. For this website I decided to make a project that was close to my heart, I decided to recreate a flipping book.
The initial idea was to show one or two pages at a time, depending on the case. Then I thought it’d be nice to add a couple of buttons that allows the user to go either to the previous or the next page.
In order to show the two pages, I had to look for a CSS property that allowed me to show those two pages at the same time. It turns out there is a property just for that. It is called “perspective”.
Additionally, I have to find a way to flip or turn those pages, so I decided to use the rotateY value that belongs to the transform property.
And finally, I recurred to Javascript so that I could add or remove, depending on the case, classes to the pages that I wanted to display or hide.
I have to be honest, this was one of those projects for which I had to make a serious effort to pull off. At the beginning I had no idea it was going to take me that much time. On occasions I got really frustrated, but I persevered because, among other things, I really wanted to accomplish the goal I set out for myself. As with other previous occasions, even when I had several moments of frustration, I have to say that I felt very proud with the final outcome.
.paper {
/* border: 1px solid red; */
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
perspective: 1500px;
}
.flipped .front,
.flipped .back {
transform: rotateY(-180deg);
}
.front {
z-index: 1;
backface-visibility: hidden;
}
Comments
Post a Comment