js+css实现电子书翻页阅读效果代码

代码语言:html

所属分类:布局界面

代码描述:js+css实现电子书翻页阅读效果代码

代码标签: js cs 电子书 翻页 阅读

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Georgia", serif;
  background: linear-gradient(135deg, #8b4513, #a0522d);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.reader-container {
  background: transparent;
  max-width: 1200px;
  width: 100%;
  position: relative;
}

.controls {
  background: rgba(139, 69, 19, 0.9);
  backdrop-filter: blur(10px);
  padding: 15px 20px;
  border-radius: 15px 15px 0 0;
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 10px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-group label {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.slider {
  width: 120px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.book-container {
  height: 700px;
  position: relative;
  perspective: 2000px;
  background: var(--bg-color, #faf7f0);
  border-radius: 0 0 15px 15px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.book {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  display: flex;
}

.book-spread {
  width: 100%;
  height: 100%;
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
}

.page-left,
.page-right {
  width: calc(50% - 20px);
  height: 100%;
  background: var(--bg-color, #faf7f0);
  padding: 50px 40px 80px 40px;
  position: relative;
}

.page-left {
  margin-right: 10px;
  border-radius: 0 8px 8px 0;
  background: radial-gradient(
      ellipse 100px 300px at 100% 50%,
      rgba(139, 69, 19, 0.03) 0%,
      transparent 50%
    ),
    linear-gradient(
      to right,
      var(--bg-color, #faf7f0) 0%,
      rgba(139, 69, 19, 0.01) 95%,
      rgba(139, 69, 19, 0.05) 100%
    ),
    var(--bg-color, #faf7f0);
  box-shadow: inset -8px 0 20px -10px rgba(139, 69, 19, 0.1),
    inset -2px 0 5px -2px rgba(139, 69, 19, 0.05);
  transform-origin: right center;
  transform: perspective(1000px) rotateY(-1deg);
}

.page-right {
  margin-left: 10px;
  border-radius: 8px 0 0 8px;
  background: radial-gradient(
      ellipse 100px 300px at 0% 50%,
      rgba(139, 69, 19, 0.03) 0%,
      transparent 50%
    ),
    linear-gradient(
      to left,
      var(--bg-color, #faf7f0) 0%,
      rgba(139, 69, 19, 0.01) 95%,
      rgba(139, 69, 19, 0.05) 100%
    ),
    var(--bg-color, #faf7f0);
  box-shadow: inset 8px 0 20px -10px rgba(139, 69, 19, 0.1),
    inset 2px 0 5px -2px rgba(139, 69, 19, 0.05);
  transform-origin: left center;
  transform: perspective(1000px) rotateY(1deg);
}

.page-content {
  width: 100%;
  height: 100%;
  line-height: 1.7;
  color: var(--text-color, #2c2c2c);
  font-size: var(--font-size, 16px);
  text-align: justify;
  text-justify: inter-word;
  word-wrap: break-word;
}

.page-content h1 {
  font-size: calc(var(--font-size, 16px) * 2);
  margin-bottom: 30px;
  text-align: center;
  color: var(--text-color, #8b4513);
  font-weight: normal;
}

.page-content h2 {
  font-size: calc(var(--font-size, 16px) * 1.5);
  margin: 30px 0 20px 0;
  color: var(--text-color, #8b4513);
  font-weight: normal;
}

.page-content p {
  margin-bottom: 18px;
  text-indent: 25px;
}

.page-number {
  position: absolute;
  bottom: 30px;
  font-size: calc(var(--font-size, 16px) * 0.8);
  color: var(--text-color, #666);
}

.page-left .page-number {
  left: 40px;
}

.page-right .page-number {
  right: 40px;
}

.binding-gutter {
  position: absolute;
  left: 50%;
  top: 0;
  width: 40px;
  height: 100%;
  transform: translateX(-50%);
  z-index: 20;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(139, 69, 19, 0.05) 20%,
    rgba(139, 69, 19, 0.1) 40%,
    rgba(139, 69, 19, 0.15) 50%,
    rgba(139, 69, 19, 0.1) 60%,
    rgba(139, 69, 19, 0.05) 80%,
    transparent 100%
  );
  box-shadow: inset 0 0 30px -5px rgba(139, 69, 19, 0.2),
    0 0 20px -5px rgba(139, 69, 19, 0.1);
}

.binding-gutter::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(139, 69, 19, 0.2) 0%,
    rgba(139, 69, 19, 0.4) 20%,
    rgba(139, 69, 19, 0.6) 50%,
    rgba(139, 69, 19, 0.4) 80%,
    rgba(139, 69, 19, 0.2) 100%
  );
  transform: translateX(-50%);
}

.flipping-page {
  position: absolute;
  top: 0;
  width: calc(50% - 10px);
  height: 100%;
  background: var(--bg-color, #faf7f0);
  transform-style: preserve-3d;
  transition: transform 0.8s ease-out;
  z-index: 10;
  border-radius: 8px;
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0