用html5写一个手机ui
我将为您展示一个完整的HTML5移动端UI设计,包含多种UI元素和交互效果:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>移动端UI展示</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
overflow-x: hidden;
color: #e0e0e0;
line-height: 1.6;
}
/* 状态栏 */
.status-bar {
height: 24px;
background: rgba(15, 32, 39, 0.8);
color: rgba(255, 255, 255, 0.85);
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 15px;
font-size: 12px;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
/* 导航栏 */
.nav-bar {
height: 56px;
background: rgba(15, 32, 39, 0.7);
display: flex;
align-items: center;
justify-content: center;
position: relative;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.nav-title {
font-size: 18px;
font-weight: 500;
color: rgba(255, 255, 255, 0.9);
}
.nav-back {
position: absolute;
left: 15px;
width: 24px;
height: 24px;
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>') no-repeat center;
background-size: contain;
}
/* 主容器 */
.container {
padding: 20px 15px;
padding-bottom: 80px;
}
/* 卡片样式 */
.card {
background: rgba(255, 255, 255, 0.08);
border-radius: 16px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
animation: slideUp 0.3s ease-out;
border: 1px solid rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
@keyframes slideUp {
from {
transform: translateY(20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
/* 按钮样式 */
.btn {
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
display: inline-block;
text-align: center;
position: relative;
overflow: hidden;
color: white;
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn:active {
transform: scale(0.98);
background: rgba(255, 255, 255, 0.25);
}
.btn-primary {
background: rgba(41, 128, 185, 0.25);
}
.btn-primary:active {
background: rgba(41, 128, 185, 0.35);
}
.btn-success {
background: rgba(39, 174, 96, 0.25);
}
.btn-success:active {
background: rgba(39, 174, 96, 0.35);
}
.btn-warning {
background: rgba(230, 126, 34, 0.25);
}
.btn-warning:active {
background: rgba(230, 126, 34, 0.35);
}
.btn-danger {
background: rgba(231, 76, 60, 0.25);
}
.btn-danger:active {
background: rgba(231, 76, 60, 0.35);
}
/* 输入框 */
.input-group {
margin-bottom: 15px;
}
.input-label {
display: block;
margin-bottom: 8px;
font-size: 14px;
color: rgba(255, 255, 255, 0.7);
}
.input-field {
width: 100%;
padding: 12px 15px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
font-size: 16px;
transition: all 0.3s ease;
background: rgba(255, 255, 255, 0.08);
color: rgba(255, 255, 255, 0.9);
}
.input-field:focus {
outline: none;
border-color: rgba(52, 152, 219, 0.5);
background: rgba(255, 255, 255, 0.12);
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
/* 列表项 */
.list-item {
padding: 15px;
background: rgba(255, 255, 255, 0.08);
border-radius: 8px;
margin-bottom: 10px;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
transition: all 0.3s ease;
border: 1px solid rgba(255, 255, 255, 0.05);
}
.list-item:active {
background: rgba(255, 255, 255, 0.15);
transform: scale(0.98);
}
.list-item-icon {
width: 40px;
height: 40px;
background: rgba(41, 128, 185, 0.3);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 18px;
margin-right: 15px;
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
}
.list-item-content {
flex: 1;
}
.list-item-title {
font-size: 16px;
color: rgba(255, 255, 255, 0.9);
margin-bottom: 4px;
}
.list-item-subtitle {
font-size: 13px;
color: rgba(255, 255, 255, 0.6);
}
/* 开关 */
.switch {
position: relative;
width: 51px;
height: 31px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.2);
transition: .4s;
border-radius: 31px;
}
.slider:before {
position: absolute;
content: "";
height: 27px;
width: 27px;
left: 2px;
bottom: 2px;
background: white;
transition: .4s;
border-radius: 50%;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
input:checked + .slider {
background: rgba(52, 152, 219, 0.5);
}
input:checked + .slider:before {
transform: translateX(20px);
background: white;
}
/* 底部导航 */
.bottom-nav {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 80px;
background: rgba(15, 32, 39, 0.7);
display: flex;
justify-content: space-around;
align-items: center;
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.bottom-nav-item {
flex: 1;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s ease;
color: rgba(255, 255, 255, 0.6);
}
.bottom-nav-item:active {
color: rgba(255, 255, 255, 0.9);
}
.bottom-nav-item.active {
color: #3498db;
}
.bottom-nav-icon {
font-size: 24px;
margin-bottom: 4px;
}
.bottom-nav-label {
font-size: 12px;
}
/* 模态框 */
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
z-index: 1000;
animation: fadeIn 0.3s ease-out;
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.modal-content {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: rgba(15, 32, 39, 0.9);
border-radius: 20px 20px 0 0;
padding: 20px;
animation: slideUpModal 0.3s ease-out;
border-top: 1px solid rgba(255, 255, 255, 0.1);
border-left: 1px solid rgba(255, 255, 255, 0.1);
border-right: 1px solid rgba(255, 255, 255, 0.1);
}
@keyframes slideUpModal {
from {
transform: translateY(100%);
}
to {
transform: translateY(0);
}
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.modal-title {
font-size: 18px;
font-weight: 500;
color: rgba(255, 255, 255, 0.9);
}
.modal-close {
width: 24px;
height: 24px;
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>') no-repeat center;
background-size: contain;
cursor: pointer;
}
/* 加载动画 */
.loader {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.1);
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* 标签页 */
.tabs {
display: flex;
background: rgba(255, 255, 255, 0.08);
border-radius: 8px;
padding: 4px;
margin-bottom: 20px;
border: 1px solid rgba(255, 255, 255, 0.05);
}
.tab {
flex: 1;
padding: 10px;
text-align: center;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s ease;
font-size: 14px;
color: rgba(255, 255, 255, 0.7);
}
.tab.active {
background: rgba(52, 152, 219, 0.3);
color: white;
}
/* 进度条 */
.progress-bar {
width: 100%;
height: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
overflow: hidden;
margin: 10px 0;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, r