天气+快递查询前端页面制作步骤(HTML,css)
搭建页面基础结构(HTML)
创建 index.html 文件,构建页面骨架,包含标题、天气查询区域、快递查询区域、结果展示区域:
天气&快递综合查询
<!-- 天气查询区域 -->
<div class="query-section weather-section">
<h2>天气指数查询(默认北京)</h2>
<button id="queryWeather">查询北京天气</button>
<!-- 天气结果展示框 -->
<div class="result-box" id="weatherResult">
<p>点击查询按钮,显示北京天气相关指数...</p>
</div>
</div>
<!-- 快递查询区域 -->
<div class="query-section express-section">
<h2>快递物流查询</h2>
<div class="express-input">
<input type="text" id="expressNo" placeholder="请输入快递单号">
<button id="queryExpress">查询快递</button>
</div>
<!-- 快递结果展示框 -->
<div class="result-box" id="expressResult">
<p>输入快递单号,点击查询按钮,显示物流信息...</p>
</div>
</div>
</div>
<!-- 引入JavaScript文件 -->
<script src="script.js"></script>
美化页面样式(CSS)
创建 style.css 文件,仿照天气预报风格设计样式,突出图标展示,优化布局:
/* 全局样式重置 */
- {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Microsoft YaHei", sans-serif;
}
body {
background-color: #f0f7ff;
padding: 20px;
}
/* 容器样式 */
.container {
max-width: 1000px;
margin: 0 auto;
background-color: #fff;
border-radius: 10px;
padding: 30px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #2d3748;
margin-bottom: 30px;
}
/* 查询区域通用样式 */
.query-section {
margin-bottom: 40px;
}
.query-section h2 {
color: #4a5568;
margin-bottom: 15px;
border-left: 4px solid #4299e1;
padding-left: 10px;
}
/* 按钮样式 */
button {
background-color: #4299e1;
color: #fff;
border: none;
padding: 8px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
}
button:hover {
background-color: #3182ce;
}
/* 快递输入区域样式 */
.express-input {
display: flex;
gap: 10px;
margin-bottom: 15px;
}
.express-input input {
flex: 1;
padding: 8px 10px;
border: 1px solid #e2e8f0;
border-radius: 4px;
font-size: 14px;
}
/* 结果展示框样式 */
.result-box {
width: 100%;
min-height: 200px;
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 20px;
background-color: #f8fafc;
}
/* 天气结果内部样式(仿照天气预报) */
.weather-info {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.weather-main {
flex: 1;
min-width: 200px;
text-align: center;
}
.weather-main img {
width: 100px;
height: 100px;
margin-bottom: 10px;
}
.weather-main .weather-text {
font-size: 24px;
color: #2d3748;
}
.weather-index {
flex: 2;
display: flex;
flex-wrap: wrap;
gap: 15px;
align-items: center;
}
.index-item {
display: flex;
flex-direction: column;
align-items: center;
width: 100px;
}
.index-item img {
width: 50px;
height: 50px;
margin-bottom: 8px;
}
.index-item .index-name {
font-size: 14px;
color: #4a5568;
}
.index-item .index-value {
font-size: 13px;
color: #718096;
}
/* 快递结果内部样式 */
.express-info {
line-height: 1.8;
}
.express-info .express-no {
font-weight: bold;
color: #4299e1;
margin-bottom: 10px;
}
.express-info .log-item {
padding: 8px 0;
border-bottom: 1px dashed #e2e8f0;
}
.express-info .log-time {
color: #718096;
font-size: 12px;
}
.express-info .log-content {
color: #4a5568;
font-size: 14px;
}

浙公网安备 33010602011771号