使用 CSS 为应用设计样式
要求:
- 在
styles.css
中添加 CSS 规则来为应用设计样式。
- 使用 CSS 创建一个现代且色彩丰富的设计。
功能:
应用 CSS 样式以使应用在视觉上更具吸引力。
步骤:
打开 styles.css
并添加以下 CSS 代码:
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #ff7f50, #ff3399);
margin: 0;
padding: 0;
color: #333;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
padding: 20px;
}
h1 {
font-size: 2rem;
margin: 20px 0;
color: #fff;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}
.input-card,
.expense-card,
.summary-card {
background: rgba(255, 255, 255, 0.9);
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2);
border-radius: 10px;
padding: 20px;
margin: 20px 0;
width: 100%;
max-width: 400px;
text-align: left;
}
.input-card h2,
.expense-card h2,
.summary-card h2 {
color: #007bff;
font-size: 1.5rem;
margin-bottom: 15px;
}
.input-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"],
input[type="number"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
background: linear-gradient(135deg, #ff3399, #ff7f50);
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
transition: background 0.3s ease;
}
button:hover {
background: linear-gradient(135deg, #ff7f50, #ff3399);
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
li {
margin-bottom: 10px;
}
/* 卡片动画 */
@keyframes fade-in {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.input-card,
.expense-card,
.summary-card {
animation: fade-in 0.5s ease;
}