书页卷边
Page Curl
页角掀起并卷曲,随着柔和阴影移动露出下一页。
适用场景
用于故事、杂志或系列图片的翻页。 为页角留出足够大的点按区域,并支持通过键盘翻页。
应用示例
一册数字旅行手记在悬停时微微卷起当前页,点按纸角就会看到下一页。
也叫
- 翻页卷曲
- 书页翻转
AI 提示词
给【卡片或文章】加上书页卷边。悬停时掀起右上角,点击或按回车时翻到下一页。给卷起的页角加一层柔和阴影。减少动态效果模式下直接换页。
示例代码
保存为 HTML 文件后,用浏览器打开即可运行。代码与页面里的演示一致。
查看 HTML
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>书页卷边</title>
<style>
:root {
color-scheme: dark;
--demo-bg: #171629;
--demo-ink: #f8f5ff;
--demo-accent: #b9a6ff;
--demo-muted: #bfbbd3;
font-family: system-ui, sans-serif;
color: var(--demo-ink);
background: var(--demo-bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; }
.demo {
display: grid;
place-items: center;
align-content: center;
min-height: 100vh;
padding: 14px;
overflow: hidden;
background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
}
.demo-button {
border: 1px solid #ffffff3d;
border-radius: 7px;
background: #ffffff12;
color: var(--demo-ink);
padding: 6px 11px;
font-size: 12px;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--demo-accent);
outline-offset: 3px;
}
.demo { background: radial-gradient(ellipse at 42% 18%, #284e48, #102928 74%); }
.book {
--curl-x: 34px;
--curl-y: 29px;
position: relative;
display: block;
width: min(100%, 236px);
height: 126px;
padding: 0;
border: 0;
border-radius: 3px;
background: #c18a59;
color: #1d3230;
box-shadow: 0 2px 0 #dec5a1, 0 4px 0 #bba488, 0 18px 30px #071c1bc2;
cursor: pointer;
perspective: 430px;
transition: background .35s ease;
}
.paper {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 5px;
padding: 15px 25px;
border-radius: inherit;
text-align: left;
}
.paper > span { font: 10px/1.2 system-ui, sans-serif; }
.paper strong { font: 400 32px/.95 Georgia, serif; letter-spacing: -.055em; }
.paper i { width: min(75%, 80px); margin-top: 6px; border-top: 1px solid currentColor; opacity: .4; }
.paper-next {
color: #482619;
background: repeating-linear-gradient(0deg, #ffffff09 0 1px, transparent 1px 3px), linear-gradient(130deg, #efcfa5, #c18a59);
box-shadow: inset 5px 0 6px #693b3b30;
}
.paper-next > span { align-self: flex-end; }
.paper-current {
color: #23403a;
background: repeating-linear-gradient(0deg, #88705208 0 1px, transparent 1px 3px), linear-gradient(115deg, #d9c8aa, #fff0cf 22%, #f7e6c7);
clip-path: polygon(0 0, calc(100% - var(--curl-x)) 0, 100% var(--curl-y), 100% 100%, 0 100%);
transform-origin: left;
transition: clip-path .35s ease, transform .46s ease, opacity .34s ease;
}
.paper-fold {
position: absolute;
top: 0;
right: 0;
width: var(--curl-x);
height: var(--curl-y);
filter: drop-shadow(-2px 4px 3px #69482580);
transition: width .35s ease, height .35s ease, opacity .2s ease;
}
.paper-fold::before {
content: '';
position: absolute;
inset: 0;
border-radius: 0 0 0 23%;
background: linear-gradient(40deg, #c29c75, #e5cfa7 26%, #fff0d0 42%, #a5805a 67%);
clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.book:is(:hover, :focus-visible) { --curl-x: 95px; --curl-y: 75px; }
.book[aria-pressed='true'] .paper-current { transform: rotateY(-82deg); opacity: 0; }
.book[aria-pressed='true'] .paper-fold { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
.book:is(:hover, :focus-visible) { --curl-x: 34px; --curl-y: 29px; }
.paper-current, .paper-fold { transition: none; }
.book[aria-pressed='true'] .paper-current { transform: none; }
}
[role="status"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
</style>
</head>
<body>
<main class="demo">
<button class="book" type="button" aria-pressed="false" aria-label="翻页">
<span class="paper paper-next" aria-hidden="true">
<span>第 2 页</span>
<strong>沿岸</strong>
<i></i>
</span>
<span class="paper paper-current" aria-hidden="true">
<span>第 1 页</span>
<strong>潮汐笔记</strong>
<i></i>
</span>
<span class="paper-fold" aria-hidden="true"></span>
</button>
<span role="status" data-on="第 2 页,沿岸" data-off="第 1 页,潮汐笔记"></span>
</main>
<script>
const button = document.querySelector('[aria-pressed]');
button.addEventListener('click', () => {
button.setAttribute('aria-pressed', String(button.getAttribute('aria-pressed') !== 'true'));
});
const status = document.querySelector('[role="status"]');
button.addEventListener('click', () => {
status.textContent = button.getAttribute('aria-pressed') === 'true' ? status.dataset.on : status.dataset.off;
});
</script>
</body>
</html>UI Skills 原创示例