代码 HTML + CSS 实现微信钱包界面

2024-11-18 14:59:25 +0800 CST views 1487

HTML + CSS 实现微信钱包界面

今天我们来实现一个微信钱包的界面,只用 HTML + CSS!这个界面虽然简单,但包含了一些有趣的 UI 设计理念,非常适合新手和进阶开发者学习如何使用基础技术复刻精美的用户界面。

界面效果预览

这个效果会模仿微信钱包的布局,包括零钱、银行卡、亲属卡等项目。


完整代码实现

HTML 代码

<style>


* {
    box-sizing: border-box;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 10px;
    background-color: #f5f5f5;
    font-size: 16px;
}
.wallet-item {
    background-color: white;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px;
}
.wallet-item-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.wallet-item-left {
    display: flex;
    align-items: center;
}
.wallet-item-amount {
    font-weight: bold;
}
.section-divider {
    height: 10px;
    background-color: #f5f5f5;
    margin: 10px 0;
}
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    .wallet-item {
        padding: 12px;
    }
    .wallet-item-icon {
        width: 20px;
        height: 20px;
    }
}
</style>
<div class="wallet-item">
    <div class="wallet-item-left">
        <span class="wallet-item-icon">¥</span>
        <span>零钱</span>
    </div>
    <span class="wallet-item-amount">¥395.16</span>
</div>

<div class="wallet-item">
    <div class="wallet-item-left">
        <span class="wallet-item-icon">?</span>
        <span>零钱通</span>
    </div>
    <div>
        <span>收益率1.42%</span>
        <span class="wallet-item-amount">¥2.70</span>
    </div>
</div>

<div class="wallet-item">
    <div class="wallet-item-left">
        <span class="wallet-item-icon">?</span>
        <span>银行卡</span>
    </div>
    <span>›</span>
</div>

<div class="wallet-item">
    <div class="wallet-item-left">
        <span class="wallet-item-icon">?</span>
        <span>亲属卡</span>
    </div>
    <span>›</span>
</div>

<div class="section-divider"></div>

<div class="wallet-item">
    <div class="wallet-item-left">
        <span class="wallet-item-icon">?</span>
        <span>分付</span>
    </div>
    <div>
        <span>按日计息,随借随还</span>
        <span>›</span>
    </div>
</div>

<div class="wallet-item">
    <div class="wallet-item-left">
        <span class="wallet-item-icon">?</span>
        <span>支付分</span>
    </div>
    <span>›</span>
</div>

<div class="wallet-item">
    <div class="wallet-item-left">
        <span class="wallet-item-icon">?</span>
        <span>消费者保护</span>
    </div>
    <span>›</span>
</div>


代码解析

  1. 布局:每个 .wallet-item 是单独的一个钱包条目,包含图标、名称、金额等信息,通过 flexbox 进行排列,保持对齐和空间分配。
  2. 图标和文字:图标是 Unicode 表情符号,样式上通过 wallet-item-icon 控制其尺寸和对齐。
  3. 响应式设计:使用 @media (max-width: 480px) 来确保在移动设备上显示更加紧凑。
  4. 间隔和分隔符:使用 .section-divider 作为不同部分之间的视觉分隔符,模仿微信钱包的设计风格。

总结

通过简单的 HTML + CSS,我们成功复刻了微信钱包的界面。这个示例展示了如何用基础的 Web 技术实现简洁、现代的 UI 界面,非常适合初学者和有经验的开发者进行练习。如果你想学习更多类似的项目,不妨继续关注!
images

复制全文 生成海报 前端开发 用户界面 Web设计

推荐文章

用 Rust 构建一个 WebSocket 服务器
2024-11-19 10:08:22 +0800 CST
Golang - 使用 GoFakeIt 生成 Mock 数据
2024-11-18 15:51:22 +0800 CST
H5端向App端通信(Uniapp 必会)
2025-02-20 10:32:26 +0800 CST
`Blob` 与 `File` 的关系
2025-05-11 23:45:58 +0800 CST
初学者的 Rust Web 开发指南
2024-11-18 10:51:35 +0800 CST
html流光登陆页面
2024-11-18 15:36:18 +0800 CST
PHP中获取某个月份的天数
2024-11-18 11:28:47 +0800 CST
CSS Grid 和 Flexbox 的主要区别
2024-11-18 23:09:50 +0800 CST
Go 中的单例模式
2024-11-17 21:23:29 +0800 CST
对多个数组或多维数组进行排序
2024-11-17 05:10:28 +0800 CST
Vue中的`key`属性有什么作用?
2024-11-17 11:49:45 +0800 CST
维护网站维护费一年多少钱?
2024-11-19 08:05:52 +0800 CST
Vue3 中提供了哪些新的指令
2024-11-19 01:48:20 +0800 CST
Go语言中实现RSA加密与解密
2024-11-18 01:49:30 +0800 CST
css模拟了MacBook的外观
2024-11-18 14:07:40 +0800 CST
程序员茄子在线接单