Posts match “ HTML5 ” tag:

授權方式(Auhorization): CC-BY 4.0

緣起

有人跟我說想要弄flipboard的翻頁效果,然後說網路上都找不到js,其實我去github一搜尋flipboard就一堆,所以有些感嘆‧‧
這篇先直接貼Source Code(僅支援Chrome),下一篇在慢慢解釋如何做到這個上下翻效果。

Mark up

html

<div class="page">
    <div class="up-side">
        <img src="http://people.cs.nctu.edu.tw/~yhsiang/.tmp/o5iUoaSbkZ6XrQ.jpg">
    </div>
    <div class="flip-side">
        <div class="front">
            <img src="http://people.cs.nctu.edu.tw/~yhsiang/.tmp/o5iUoaSbkZ6XrQ.jpg">
        </div>
        <div class="back">
            <img src="http://people.cs.nctu.edu.tw/~yhsiang/.tmp/tumblr_mjlk374tQa1riz7dgo1_500.jpg">
        </div>
    </div>
    <div class="down-side">
        <img src="http://people.cs.nctu.edu.tw/~yhsiang/.tmp/tumblr_mjlk374tQa1riz7dgo1_500.jpg">
    </div>
</div>

css

.page {
    width: 500px;
    height: 667px;
    position: absolute;
    -webkit-perspective: 1000;
}
.page .up-side, .page .flip-side {
    position: absolute;
    height: 50%;
    width: 100%;
    -webkit-transform-origin: 0 0 0;
    -webkit-transform-style: preserve-3d;
    transition: all 3000ms ease-in-out;
    overflow: hidden;
}

.page:hover .flip-side {
    -webkit-transform: rotateX(180deg) translate3d(0, 0, 0);
}

.page:hover .flip-side .front {
    z-index: 0;
}

.page .up-side {
    top: 0;
    bottom: auto;

}

.page .flip-side {
    bottom: 0;
    top: auto;
}

.page .flip-side img {
    position: absolute;
    bottom: 0;
    height: auto;
}

.front {
    z-index: 1;
}

.front, .back {
    -webkit-backface-visibility: hidden;
    position: absolute;
    height: 100%;
    width: 100%;
    transition: all 3000ms ease-in-out;
}

.back img {
    -webkit-transform: rotateX(180deg);
}