css实现一个鼠标悬浮翻书动画效果代码

代码语言:html

所属分类:悬停

代码描述:css实现一个鼠标悬浮翻书动画效果代码

代码标签: 鼠标 悬浮 翻书 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en" >

<head>

    <meta charset="UTF-8" />
    <style>
        @import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600&subset=latin,latin-ext);
    
    
    
    .container > header,
    .codrops-top {
    	font-family: 'Lato', Arial, sans-serif;
    	color: #34495e;
    }
    
    .container > header {
    	margin: 0 auto;
    	padding: 2em;
    	text-align: center;
    	background: #34495e;
    	color: #fff;
    }
    
    .container > header h1 {
    	font-size: 2.625em;
    	line-height: 1.3;
    	margin: 0;
    	font-weight: 300;
    }
    
    .container > header span {
    	display: block;
    	font-size: 60%;
    	color: #16a085;
    	padding: 0 0 0.6em 0.1em;
    }
    
    /* To Navigation Style */
    .codrops-top {
    	background: #253749;
    	text-transform: uppercase;
    	width: 100%;
    	font-size: 0.69em;
    	line-height: 2.2;
    }
    
    .codrops-top a {
    	text-decoration: none;
    	padding: 0 1em;
    	letter-spacing: 0.1em;
    	color: #fff;
    	display: inline-block;
    }
    
    .codrops-top a:hover {
    	background: rgba(255,255,255,0.1);
    	color: #fff;
    }
    
    .codrops-top span.right {
    	float: right;
    }
    
    .codrops-top span.right a {
    	float: left;
    	display: block;
    }
    
    .codrops-icon:before {
    	font-family: 'codropsicons';
    	margin: 0 4px;
    	speak: none;
    	font-style: normal;
    	font-weight: normal;
    	font-variant: normal;
    	text-transform: none;
    	line-height: 1;
    	-webkit-font-smoothing: antialiased;
    }
    
    .codrops-icon-drop:before {
    	content: "\e001";
    }
    
    .codrops-icon-prev:before {
    	content: "\e004";
    }
    
    /* Demo Buttons Style */
    .codrops-demos {
    	padding-top: 1em;
    	font-size: 0.9em;
    }
    
    .codrops-demos a {
    	text-decoration: none;
    	outline: none;
    	display: inline-block;
    	margin: 0.5em;
    	font-size: 1.1em;
    	padding: 0.7em 1.1em;
    	border: 3px solid #16a085;
    	color: #16a085;
    	font-weight: 700;
    }
    
    .codrops-demos a:hover,
    .codrops-demos a.current-demo,
    .codrops-demos a.current-demo:hover {
    	border-color: #fff;
    	color: #fff;
    }
    
    p.note {
    	font-size: 1.1em;
    	text-align: center;
    	padding: 40px 10px 100px;
    	max-width: 700px;
    	margin: 0 auto;
    	line-height: 1.4;
    }
    
    @media screen and (max-width: 25em) {
    
    	.codrops-icon span {
    		display: none;
    	}
    
    }
    
    /*
    	A. Mini Reset 
    */
    *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
    
    * {
      margin: 0;
      padding: 0;
    }
    
    ::before,
    ::after {
    	content: "";
    }
    
    html,
    body {
    	height: 100%;
    	-webkit-font-smoothing: subpixel-antialiased;
    }
    
    html {
    	font-size: 100%;
    }
    
    body {
    	background: #ecf0f1;
    	color: #34495e;
    	font-family: 'Lato', 'Arial', sans-serif;
    	font-weight: 400;
    	line-height: 1.2;
    }
    
    ul {
    	margin: 0;
    	padding: 0;
    	list-style: none;
    }
    
    a {
    	color: #2c3e50;
    	text-decoration: none;
    }
    
    .btn {
    	display: inline-block;
    	text-transform: uppercase;
    	border: 2px solid #2c3e50;
    	margin-top: 100px; 
    	font-size: 0.7em;
    	font-weight: 700;
    	padding: 0.1em 0.4em;
    	text-align: center;
    	-webkit-transition: color 0.3s, border-color 0.3s;
    	-moz-transition: color 0.3s, border-color 0.3s;
    	transition: color 0.3s, border-color 0.3s;
    }
    
    .btn:hover {
    	border-color: #16a085;
    	color: #16a085;
    }
    
    /* basic grid, only for this demo */
    
    .align {
    	clear: both;
    	margin: 90px auto 20px;
    	width: 100%;
    	max-width: 1170px;
    	text-align: center;
    }
    
    .align > li {
    	width: 500px;
    	min-height: 300px;
    	display: inline-block;
    	margin: 30px 20px 30px 30px;
    	padding: 0 0 0 60px;
    	vertical-align: top;
    }
    
    /* ///////////////////////////////////////////////////
    
    HARDCOVER
    Table of Contents
    
    1. container
    2. background & color
    3. opening cover, back cover and pages
    4. position, transform y transition
    5. events
    6. Bonus
    	- Cover design
    	- Ribbon
    	- Figcaption
    7. mini-reset
    
    /////////////////////////////////////////////////////*/
    
    /*
    	1. container
    */
    
    .book {
    	position: relative;
    	width: 160px; 
    	height: 220px;
    	-webkit-perspective: 1000px;
    	-moz-perspective: 1000px;
    	perspective: 1000px;
    	-webkit-transform-style: preserve-3d;
    	-moz-transform-style: preserve-3d;
    	transform-style: preserve-3d;
    }
    
    /*
    	2. background & color
    */
    
    /* HARDCOVER FRONT */
    .hardcover_front li:first-child {
    	background-color: #eee;
    	-webkit-backface-visibility: hidden;
    	-moz-backface-visibility: hidden;
    	backface-visibility: hidden;
    }
    
    /* reverse */
    .hardcover_front li:last-child {
    	background: #fffbec;
    }
    
    /* HARDCOVER BACK */
    .hardcover_back li:first-child {
    	background: #fffbec;
    }
    
    /* reverse */
    .hardcover_back li:last-child {
    	background: #fffbec;
    }
    
    .book_spine li:first-child {
    	background: #eee;
    }
    .book_spine li:last-child {
    	background: #333;
    }
    
    /* thickness of cover */
    
    .hardcover_front li:first-child:after,
    .hardcover_front li:first-child:before,
    .hardcover_front li:last-child:after,
    .hardcover_front li:last-child:before,
    .hardcover_back li:first-child:after,
    .hardcover_back li:first-child:before,
    .hardcover_back li:last-child:after,
    .hardcover_back li:last-child:before,
    .book_spine li:first-child:after,
    .book_spine li:first-child:before,
    .book_spine li:last-child:after,
    .book_spine li:last-child:before {
    	background: #999;
    }
    
    /* page */
    
    .page > li {
    	background: -webkit-linear-gradient(left, #e1ddd8 0%, #fffbf6 100%);
    	background: -moz-linear-gradient(left, #e1ddd8 0%, #fffbf6 100%);
    	background: -ms-linear-gradient(left, #e1ddd8 0%, #fffbf6 100%);
    	background: linear-gradient(left, #e1ddd8 0%, #fffbf6 100%);
    	box-shadow: inset 0px -1px 2px rgba(50, 50, 50, 0.1), inset -1px 0px 1px rgba(150, 150, 150, 0.2);
    	border-radius: 0px 5px 5px 0px;
    }
    
    /*
    	3. opening cover, back cover and pages
    */
    
    .hardcover_front {
    	-webkit-transform: rotateY(-34deg) translateZ(8px);
    	-moz-transform: rotateY(-34deg) translateZ(8px);
    	transform: rotateY(-34deg) translateZ(8px);
    	z-index: 100;
    }
    
    .hardcover_back {
    	-webkit-transform: rotateY(-15deg) translateZ(-8px);
    	-moz-transform: rotateY(-15deg) translateZ(-8px);
    	transform: rotateY(-15deg) translateZ(-8px);
    }
    
    .page li:nth-child(1) {
    	-webkit-transform: rotateY(-28deg);
    	-moz-transform: rotateY(-28deg);
    	transform: rotateY(-28deg);
    }
    
    .page li:nth-child(2) {
    	-webkit-transform: rotateY(-30deg);
    	-moz-transform: rotateY(-30deg);
    	transform: rotateY(-30deg);
    }
    
    .page li:nth-child(3) {
    	-webkit-transform: rotateY(-32deg);
    	-moz-transform: rotateY(-32deg);
    	transform: rotateY(-32deg);
    }
    
    .page li:nth-child(4) {
    	-webkit-transform: rotateY(-34deg);
    	-moz-transform: rotateY(-34deg);
    	transform: rotateY(-34deg);
    }
    
    .page li:nth-child(5) {
    	-webkit-transform: rotateY(-36deg);
    	-moz-transform: rotateY(-36deg);
    	transform: rotateY(-36deg);
    }
    
    /*
    	4. position, transform & transition
    */
    
    .hardcover_front,
    .hardcover_back,
    .book_spine,
    .hardcover_front li,
    .hardcover_back li,
    .book_spine li {
    	position: absolute;
    	top: 0;
    	left: 0;
    	width: 100%;
    	height: 100%;
    	-webkit-transform-style: preserve-3d;
    	-moz-transform-style: preserve-3d;
    	transform-style: preserve-3d;
    }
    
    .hardcover_front,
    .hardcover_back {
    	-webkit-transform-origin: 0% 100%;
    	-moz-transform-origin: 0% 100%;
    	transform-origin: 0% 100%;
    }
    
    .hardcover_front {
    	-webkit-transition: all 0.8s ease, z-index 0.6s;
    	-moz-transition: all 0.8s ease, z-index 0.6s;
    	transition: all 0.8s ease, z-index 0.6s;
    }
    
    /* HARDCOVER front */
    .hardcover_front li:first-child {
    	cursor: default;
    	-webkit-user-select: none;
    	-moz-user-select: none;
    	user-select: none;
    	-webkit-transform: translateZ(2px);
    	-moz-transform: translateZ(2px);
    	transform: translateZ(2px);
    }
    
    .hardcover_front li:last-child {
    	-webkit-transform: rotateY(180deg) translateZ(2px);
    	-moz-transform: rotateY(180deg) translateZ(2px);
    	transform: rotateY(180deg) translateZ(2px);
    }
    
    /* HARDCOVER back */
    .hardcover_back li:first-child {
    	-webkit-transform: translateZ(2px);
    	-moz-transform: translateZ(2px);
    	transform: translateZ(2px);
    }
    
    .hardcover_back li:last-child {
    	-webkit-transform: translateZ(-2px);
    	-moz-transform: translateZ(-2px);
    	transform: translateZ(-2px);
    }
    
    /* thickness of cover */
    .hardcover_front li:first-child:after,
    .hardcover_front li:first-child:before,
    .hardcover_front li:last-child:after,
    .hardcover_front li:last-child:before,
    .hardcover_back li:first-child:after,
    .hardcover_back li:first-child:before,
    .hardcover_back li:last-child:after,
    .hardcover_back li:last-child:before,
    .book_spine li:first-child:after,
    .book_spine li:first-child:before,
    .book_spine li:last-child:after,
    .book_spine li:last-child:before {
    	position: absolute;
    	top: 0;
    	left: 0;
    }
    
    /* HARDCOVER front */
    .hardcover_front li:first-child:after,
    .hardcover_front li:first-child:before {
    	width: 4px;
    	height: 100%;
    }
    
    .hardcover_front li:first-child:after {
    	-webkit-transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    	-moz-transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    	transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    }
    
    .hardcover_front li:first-child:before {
    	-webkit-transform: rotateY(90deg) translateZ(158px) translateX(2px);
    	-moz-transform: rotateY(90deg) translateZ(158px) translateX(2px);
    	transform: rotateY(90deg) translateZ(158px) translateX(2px);
    }
    
    .hardcover_front li:last-child:after,
    .hardcover_front li:last-child:before {
    	width: 4px;
    	height: 160px;
    }
    
    .hardcover_front li:last-child:after {
    	-webkit-transform: rotateX(90deg) rotateZ(90deg) translateZ(80px) translateX(-2px) translateY(-78px);
    	-moz-transform: rotateX(90deg) rotateZ(90deg) translateZ(80px) translateX(-2px) translateY(-78px);
    	transform: rotateX(90deg) rotateZ(90deg) translateZ(80px) translateX(-2px) translateY(-78px);
    }
    .hardcover_front li:last-child:before {
    	box-shadow: 0px 0px 30px 5px #333;
    	-webkit-transform: rotateX(90deg) rotateZ(90deg) translateZ(-140px) translateX(-2px) translateY(-78px);
    	-moz-transform: rotateX(90deg) rotateZ(90deg) translateZ(-140px) translateX(-2px) translateY(-78px);
    	transform: rotateX(90deg) rotateZ(90deg) translateZ(-140px) translateX(-2px) translateY(-78px);
    }
    
    /* thickness of cover */
    
    .hardcover_back li:first-child:after,
    .hardcover_back li:first-child:before {
    	width: 4px;
    	height: 100%;
    }
    
    .hardcover_back li:first-child:after {
    	-webkit-transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    	-moz-transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    	transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    }
    .hardcover_back li:first-child:before {
    	-webkit-transform: rotateY(90deg) translateZ(158px) translateX(2px);
    	-moz-transform: rotateY(90deg) translateZ(158px) translateX(2px);
    	transform: rotateY(90deg) translateZ(158px) translateX(2px);
    }
    
    .hardcover_back li:last-child:after,
    .hardcover_back li:last-child:before {
    	width: 4px;
    	height: 160px;
    }
    
    .hardcover_back li:last-child:after {
    	-webkit-transform: rotateX(90deg) rotateZ(90deg) translateZ(80px) translateX(2px) translateY(-78px);
    	-moz-transform: rotateX(90deg) rotateZ(90deg) translateZ(80px) translateX(2px) translateY(-78px);
    	transform: rotateX(90deg) rotateZ(90deg) translateZ(80px) translateX(2px) translateY(-78px);
    }
    
    .hardcover_back li:last-child:before {
    	box-shadow: 10px -1px 80px 20px #666;
    	-webkit-transform: rotateX(90deg) rotateZ(90deg) translateZ(-140px) translateX(2px) translateY(-78px);
    	-moz-transform: rotateX(90deg) rotateZ(90deg) translateZ(-140px) translateX(2px) translateY(-78px);
    	transform: rotateX(90deg) rotateZ(90deg) translateZ(-140px) translateX(2px) translateY(-78px);
    }
    
    /* BOOK SPINE */
    .book_spine {
    	-webkit-transform: rotateY(60deg) translateX(-5px) translateZ(-12px);
    	-moz-transform: rotateY(60deg) translateX(-5px) translateZ(-12px);
    	transform: rotateY(60deg) translateX(-5px) translateZ(-12px);
    	width: 16px;
    	z-index: 0;
    }
    
    .book_spine li:first-child {
    	-webkit-transform: translateZ(2px);
    	-moz-transform: translateZ(2px);
    	transform: translateZ(2px);
    }
    
    .book_spine li:last-child {
    	-webkit-transform: translateZ(-2px);
    	-moz-transform: translateZ(-2px);
    	transform: translateZ(-2px);
    }
    
    /* thickness of book spine */
    .book_spine li:first-child:after,
    .book_spine li:first-child:before {
    	width: 4px;
    	height: 100%;
    }
    
    .book_spine li:first-child:after {
    	-webkit-transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    	-moz-transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    	transform: rotateY(90deg) translateZ(-2px) translateX(2px);
    }
    
    .book_spine li:first-child:before {
    	-webkit-transform: rotateY(-90deg) translateZ(-12px);
    	-moz-transform: rotateY(-90deg) translateZ(-12px);
    	transform: rotateY(-90deg) translateZ(-12px);
    }
    
    .book_spine li:last-child:after,
    .book_spine li:last-child:before {
    	width: 4px;
    	height: 16px;
    }
    
    .book_spine li:last-child:after {
    	-webkit-transform: rotateX(90deg) rotateZ(90deg) translateZ(8px) translateX(2px) translateY(-6px);
    	-moz-transform: rotateX(90deg) rotateZ(90deg) translateZ(8px) translateX(2px) translateY(-6px);
    	transform: rotateX(90deg) rotateZ(90deg) translateZ(8px) translateX(2px) translateY(-6px);
    }
    
    .book_spine li:last-child:before {
    	box-shadow: 5px -1px 100px 40px rgba(0, 0, 0, 0.2);
    	-webkit-transform: rotateX(90deg) rotateZ(90deg) translateZ(-210px) translateX(2px) translateY(-6px);
    	-moz-transform: rotateX(90deg) rotateZ(90deg) translateZ(-210px) translateX(2px) translateY(-6px);
    	transform: rotateX(90deg) rotateZ(90deg) translateZ(-210px) translateX(2px) translateY(-6px);
    }
    
    .page,
    .page > li {
    	position: absolute;
    	top: 0;
    	left: 0;
    	-webkit-transform-style: preserve-3d;
    	-moz-transform-style: preserve-3d;
    	transform-style: preserve-3d;
    }
    
    .page {
    	width: 100%;
    	height: 98%;
    	top: 1%;
    	left: 3%;
    	z-index: 10;
    }
    
    .page > li {
    	width: 100%;
    	height: 100%;
    	-webkit-transform-origin: left center;
    	-moz-transform-origin: left center;
    	tran.........完整代码请登录后点击上方下载按钮下载查看

网友评论0