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: paymen.........完整代码请登录后点击上方下载按钮下载查看

网友评论0