js+div实现交易列表点击查看详情视图转换效果代码
代码语言:html
所属分类:其他
代码描述:js+div实现交易列表点击查看详情视图转换效果代码
代码标签: js div 交易 列表 点击 查看 详情 视图 转换
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
font-family: system-ui, -apple-system, sans-serif;
background: #fafafa;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background: white;
border-radius: 24px;
padding: 16px 12px;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
view-transition-name: container;
width: 400px;
height: fit-content;
}
.list-header {
font-size: 20px;
font-weight: 500;
color: #18181b;
margin-bottom: 24px;
padding-left: 12px;
view-transition-name: list-header;
height: fit-content;
overflow: hidden;
}
.close-button {
display: none;
justify-content: flex-end;
view-transition-name: close-button;
}
.not-expanded {
view-transition-class: not-expanded;
* {
view-transition-class: not-expanded;
}
}
.container:has(.not-expanded) :is(.list-header, .all-transactions) {
view-transition-class: not-expanded;
}
.container:has(.expanded) {
.list-header {
display: none;
}
.close-button {
display: flex;
}
.all-transactions {
display: none;
}
.transaction:not(.expanded) {
display: none;
}
}
.transaction-list {
display: flex;
flex-direction: column;
gap: 16px;
view-transition-name: transaction-list;
}
.transaction {
display: flex;
align-items: center;
gap: 12px;
padding: 0 12px;
border-radius: 16px;
cursor: pointer;
&.expanded {
flex-direction: column;
align-items: flex-start;
background: #ffffff;
.transaction-details,
.payment-details {
display: flex;
}
.icon-container {
width: 100%;
.close-btn {
display: flex;
}
}
}
}
.title-container {
display: flex;
flex-direction: column;
gap: 4px;
}
.icon-container {
display: flex;
justify-content: space-between;
}
.icon {
width: 40px;
height: 40px;
background: #18181b;
border-radius: 12px;
display: grid;
place-items: center;
}
.icon svg {
width: 20px;
height: 20px;
color: white;
}
.details {
display: flex;
flex-direction: row;
justify-content: space-between;
flex: 1;
width: 100%;
}
.title {
font-weight: 500;
color: #18181b;
margin-bottom: 4px;
}
.subtitle {
font-size: 14px;
color: #71717a;
}
.amount {
font-weight: 500;
color: #71717a;
}
.transaction-details,
.payment-details {
display: flex;
flex-direction: column;
gap: 6px;
color: #71717a;
border-top: 1px dotted #71717a;
padding-top: 6px;
width: 100%;
display: none;
}
.transaction-details {
view-transition-class: transaction-details;
}
.payment-details {
view-transition-class: payment-details;
}
.all-transactions {
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
color: #18181b;
font-weight: 500;
margin-top: 8px;
cursor: pointer;
view-transition-name: all-transactions;
}
.close-btn {
width: 32px;
height: 32px;
border: none;
background: #f4f4f5;
border-radius: 50%;
cursor: pointer;
display: none;
align-items: center;
justify-content: center;
}
@keyframes slide-up {
from {
opacity: 0;
margin-top: 30px;
}
to {
opacity: 1;
margin-top: 0;
}
}
@keyframes fade-out {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@keyframes squash {
0% {
transform: scaleY(1);
}
100% {
transform: scaleY(0);
}
}
::view-transition-group(*) {
animation-duration: 0.4s;
animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1);
}
::view-transition-old(*),
::view-transition-new(*) {
height: 100%;
}
html:active-view-transition-type(expand) {
&::view-transition-group(.transaction-details),
&::view-transition-group(.payment-details) {
animation-name: slide-up;
animation-duration: 0.5s;
}
}
html:active-view-transition-type(collapse) {
&::view-transition-group(.transaction-details),
&::view-transition-group(.payment-details) {
animation-name: fade-out;
}
}
::view-transition-group(.not-expanded) {
animation-name: fade-out;
}
</style>
</head>
<body translate="no">
<div class="container">
<div class="list-header">Transactions</div>
<div class="transaction-list">
<div class="transaction" style="view-transition-name: transaction-1">
<div class="icon-container">
<div class="icon" style="view-transition-name: icon-1">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
<path d="M3 3h18v18H3z" stroke-width="2"/>
<path d="M9 12h6M12 9v6" stroke-width="2" stroke-linecap="round"/>
</svg>
</div>
<button class="close-btn" style="view-transition-name: close-btn-1">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor">
<path d="M12 4L4 12M4 4l8 8" stroke-width="2" stroke-linecap="round"/>
</svg>
</button>
</div>
<div class="details">
<div class="title-container" style="view-transition-name: title-container-1&.........完整代码请登录后点击上方下载按钮下载查看
网友评论0