公交车路线图HTMLcss
时间: 2023-07-25 15:29:49 浏览: 42
以下是一个基本的 HTML 和 CSS 实现公交车路线图的示例:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>公交车路线图</title>
<style>
/* 设置地图的样式 */
#map {
width: 600px;
height: 400px;
background-color: #f2f2f2;
border: 1px solid #ccc;
margin: 20px;
position: relative;
}
/* 设置公交车站点的样式 */
.station {
width: 10px;
height: 10px;
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 id="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>
</body>
</html>
```
在这个示例中,我使用一个 `div` 元素作为地图容器,并设置了它的宽度、高度、背景颜色、边框和位置。我使用绝对定位来放置公交车站点和路线,并为它们设置样式。我还使用 `.station-label` 类来显示公交车站点的名称。
你可以根据需要添加更多的公交车站点和路线。你还可以使用 JavaScript 代码来动态地生成公交车站点和路线,以便在需要时自动更新地图。