flex公交车路线图HTMLcss
时间: 2023-07-12 09:29:14 浏览: 67
你需要一个基本的 HTML 页面,包括一个 `div` 元素来显示地图。然后,你可以使用 CSS 样式来布置地图的样式。
以下是一个简单的 HTML 页面示例,其中包括使用 Flexbox 布局的样式:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Flex公交车路线图</title>
<style>
/* 设置容器为 Flexbox 布局 */
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
/* 设置地图的样式 */
.map {
width: 600px;
height: 400px;
background-color: #f2f2f2;
border: 1px solid #ccc;
margin: 20px;
}
/* 设置公交车站点的样式 */
.station {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #333;
position: absolute;
}
/* 设置公交车站点名称的样式 */
.station-label {
position: absolute;
top: -20px;
left: 0;
font-size: 12px;
}
/* 设置公交车路线的样式 */
.route {
position: absolute;
width: 4px;
height: 4px;
background-color: #333;
}
/* 设置公交车路线的起点和终点样式 */
.route.start,
.route.end {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #333;
}
</style>
</head>
<body>
<div class="container">
<div class="map">
<div class="station" style="top: 50px; left: 50px;"></div>
<div class="station-label" style="top: 30px; left: 50px;">站点1</div>
<div class="station" style="top: 100px; left: 150px;"></div>
<div class="station-label" style="top: 80px; left: 150px;">站点2</div>
<div class="station" style="top: 200px; left: 250px;"></div>
<div class="station-label" style="top: 180px; left: 250px;">站点3</div>
<div class="station" style="top: 300px; left: 350px;"></div>
<div class="station-label" style="top: 280px; left: 350px;">站点4</div>
<div class="route start" style="top: 50px; left: 50px;"></div>
<div class="route" style="top: 100px; left: 150px;"></div>
<div class="route" style="top: 200px; left: 250px;"></div>
<div class="route end" style="top: 300px; left: 350px;"></div>
</div>
</div>
</body>
</html>
```
以上代码中,我创建了一个 `.container` 容器,其中包含一个 `.map` 元素,它显示了公交车路线图。我使用绝对定位来放置公交车站点和路线,以便我可以精确控制它们的位置。我还使用 `.station-label` 类来显示公交车站点的名称。
你可以根据需要添加更多的公交车站点和路线。你还可以使用 JavaScript 代码来动态地生成公交车站点和路线,以便在需要时自动更新地图。