This article introduces CSS to achieve 3D book effect through code examples. The code is simple and easy to understand. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Without further ado, let’s take a look at the renderings
The source code is as follows
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> *{ margin: 0; padding: 0; } body{ display: flex; align-items: center; justify-content: center; width: 100%; min-height: 100vh; background: #333333; background-size: cover; } .book{ width: 400px; height: 600px; position: relative; background-color: #ffffff; transform: rotate(-37.5deg) skewX(10deg); box-shadow: -35px 35px 50px rgb(0,0, 0, 1); transition: 0.5s; /* 光标呈现为指示链接的指针(一只手) */ cursor: pointer; } .book:hover{ /* rotate 定义 2D 旋转,在参数中规定角度。 */ /* skewX()定义沿着 X 轴的 2D 倾斜转换。 translate(x,y) 定义 2D 转换。 */ transform: rotate(-37.5deg) skewX(10deg) translate(20px,-20px); /* box-shadow 向框添加一个或多个阴影 */ box-shadow: -50px 50px 100px rgba(0,0,0,1); } /* 伪元素必须配合content进行使用,至少为空 */ .book::before{ content:''; height:100%; width:30px; background: red; position: absolute; top: 0; left: 0; transform: skewY(-45deg) translate(-30px,-15px); box-shadow: inset -10px 0 20px raba(0,0,0,0,2); background: url(cofe.jpg); } .book::after{ content: ''; height: 30px; width: 100%; background: #fff; position: absolute; bottom: 0; left: 0; transform: skewX(-45deg) translate(15px,30px); background: url(cofe.jpg); } .book h2{ position: absolute; bottom: 100px; left: 10px; font-size: 5em; line-height: 1em; color: rgb(110, 21, 21); } .book h2 span{ background-image: url(cofe.jpg); background-attachment: fixed; -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .book .write i{ font-weight: 700; } .book .cover{ position: absolute; top: 0; left: 0; width: 100%; height: 70%; background-image: url(cofe.jpg); background-size: cover; } </style> <body> <div> <div></div> <h2 id="Book-nbsp-span-javascript-span">Book <span>javascript</span></h2> <span> written by fans</span> </div> </body> </html>
ok, the effect is still relatively good. , if you like it, please give it a like! ! !
Recommended related tutorials: CSS video tutorial
More cool CSS3, html5, javascript special effects codes, all at:js special effects collection!
The above is the detailed content of How to achieve 3D book effect using pure CSS? (code example). For more information, please follow other related articles on the PHP Chinese website!

I recently found a solution to dynamically update the color of any product image. So with just one of a product, we can colorize it in different ways to show

In this week's roundup, Lighthouse sheds light on third-party scripts, insecure resources will get blocked on secure sites, and many country connection speeds

There are loads of analytics platforms to help you track visitor and usage data on your sites. Perhaps most notably Google Analytics, which is widely used

The document head might not be the most glamorous part of a website, but what goes into it is arguably just as important to the success of your website as its

What's happening when you see some JavaScript that calls super()?.In a child class, you use super() to call its parent’s constructor and super. to access its

JavaScript has a variety of built-in popup APIs that display special UI for user interaction. Famously:

I was chatting with some front-end folks the other day about why so many companies struggle at making accessible websites. Why are accessible websites so hard

There is an HTML attribute that does exactly what you think it should do:


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.