(飛肯) CSS3 透視效果

perspective-page-view-navigation-01 

Some effects for a perspective page view navigation where the page itself gets pushed away in 3D to reveal a menu or other items. This navigation idea is seen in mobile app design and we wanted to explore some more effects.

 

Pushing the site content aside to reveal a navigation has certainly become a trend for mobile navigations. The approach reflects some practices in app design where “views” are shown with animations. We’ve experimented a bit and we’ve come up with a small set of effects that take the page and move it in 3D to reveal a navigation (or some other content if you like). What’s nice about this is that we literally put the site into perspective, allowing for an interesting view on the content and the navigation possibilities.

 

Please note that this is highly experimental, so let us know if you find any bugs or problems.

For the general effect to work, we need to wrap our page into a perspective wrapper. The main content container (that will get moved in 3D) and the navigation will be the two children immediate children of that wrapper:

1
2
3
4
5
6
7
8
9
10
<div id="perspective" class="perspective effect-airbnb">
    <div class="container">
        <div class="wrapper"><!-- wrapper needed for scroll -->
            <!-- ... -->
        </div><!-- wrapper -->
    </div><!-- /container -->
    <nav class="outer-nav left vertical">
        <!-- ... -->
    </nav>
</div><!-- /perspective -->

When we trigger the effect, we’ll need to change the position and overflow of the divisions to just show the current view. With a little trick we can hide the overflow but keep the scroll position by setting the “wrapper” top to the negative scrollTop value of the body.

Depending on which effect we have set as a class to the perspective wrapper, we’ll animate the container and the menu items once we click the trigger button. An example for an effect is the following, where we rotate and move the page to the left and make the navigation items appear consecutively with a slight delay on the right side:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Effect Move Left */
.effect-moveleft {
    background: #f4f3f1;
}
 
.effect-moveleft .container {
    transition: transform 0.4s;
    transform-origin: 50% 50%;
}
 
.effect-moveleft .container::after {
    background: rgba(255,255,255,0.6);
}
 
.effect-moveleft.animate .container {
    transform: translateX(-50%) rotateY(45deg) translateZ(-50px);
}
 
/* Fallback */
.no-csstransforms3d .effect-moveleft.animate .container {
    left: -75%;
}
 
/* Navigation */
.effect-moveleft .outer-nav a {
    color: #e86a32;
    opacity: 0;
    transform: translateX(100px) translateZ(-1000px);
    transition: transform 0.4s, opacity 0.4s;
}
 
.effect-moveleft .outer-nav a:hover {
    color: #333;
}
 
.effect-moveleft.animate .outer-nav a {
    opacity: 1;
    transform: translateX(0) translateZ(0);
}
 
.effect-moveleft.animate .outer-nav a:nth-child(2) {
    transition-delay: 0.04s;
}
 
.effect-moveleft.animate .outer-nav a:nth-child(3) {
    transition-delay: 0.08s;
}
 
.effect-moveleft.animate .outer-nav a:nth-child(4) {
    transition-delay: 0.12s;
}
 
.effect-moveleft.animate .outer-nav a:nth-child(5) {
    transition-delay: 0.16s;
}
 
.effect-moveleft.animate .outer-nav a:nth-child(6) {
    transition-delay: 0.2s;
}
 
.effect-moveleft.animate .outer-nav a:nth-child(7) {
    transition-delay: 0.24s;
}

We also added some example media queries that show how to resize or reposition the menu for smaller screens.

There are two styles for the menus which is a horizontal and a vertical one. Depending on where we push away the page, we’ll be using one of the orientations together with a position class:

1
2
3
4
5
6
7
8
9
<nav class="outer-nav left vertical">
    <a href="#" class="icon-home">Home</a>
    <a href="#" class="icon-news">News</a>
    <a href="#" class="icon-image">Images</a>
    <a href="#" class="icon-upload">Uploads</a>
    <a href="#" class="icon-star">Favorites</a>
    <a href="#" class="icon-mail">Messages</a>
    <a href="#" class="icon-lock">Security</a>
</nav>

The icons used in the demo are from the Typicons set by Stephen Hutchings and they are licensed under the CC BY-SA 3.0 license.

 

Here is how all the effects look like when the menu is visible and the page is pushed away:

 

Airbnb Effect:

perspective-page-view-navigation-02

 

Move Left:

perspective-page-view-navigation-03

 

Rotate Left:

perspective-page-view-navigation-04

 

Move Down:

perspective-page-view-navigation-05

 

Rotate Top:

perspective-page-view-navigation-06

 

Lay down:

perspective-page-view-navigation-07

 

http://tympanus.net/codrops/2013/12/18/perspective-page-view-navigation/?utm_content=bufferea9c3&utm_source=buffer&utm_medium=twitter&utm_campaign=Buffer