在网页开发中,天气预报数据的展示效果直接影响用户体验。本文将详细介绍如何为天气预报中的各个元素添加专业的CSS样式。
<div class="weather-container">
<span class="weather-date">2023-12-25</span>
<span class="weather-time">14:30:00</span>
<span class="weather-temp">25℃</span>
</div>
.weather-date {
font-family: 'Arial', sans-serif;
font-size: 18px;
color: #333;
font-weight: bold;
margin-right: 10px;
}
.weather-time {
font-family: 'Courier New', monospace;
font-size: 16px;
color: #666;
background-color: #f5f5f5;
padding: 2px 5px;
border-radius: 3px;
}
.weather-temp {
font-size: 24px;
font-weight: bold;
color: #e74c3c;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
margin-left: 10px;
}
.weather-container {
background: linear-gradient(to right, #f8f9fa, #e9ecef);
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: inline-block;
}
@media (max-width: 768px) {
.weather-date, .weather-time, .weather-temp {
display: block;
margin: 5px 0;
}
}
.weather-temp:hover {
transform: scale(1.1);
transition: transform 0.3s ease;
}
通过以上CSS样式设计,您的天气预报显示将更加专业美观,提升用户体验。根据实际需求,您可以调整颜色、大小和间距等参数,打造独特的视觉效果。