如何设计 css "metro line" 没有车站或线路名称覆盖的布局
How to design css layout of "metro line" without station or line name cover
我有一系列地铁线路和车站。我要做的是显示line names on the up center of line
,显示station names right below the station
,线路和车站是相连的。
重要的是line names shouldn't exceed line, and shouldn't cover other line names
和station names should also not cover other station names
,无论站名或线路名多长。
现在的问题是站名太长会覆盖其他站名。
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre><code>.main{
margin-top: 32px;
margin-left: 32px;
display: flex;
flex-direction: row;
justify-content: left;
align-items: center;
}
.line{
height: 2px;
min-width: 32px;
border-bottom: 2px solid;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
}
.line-name{
margin: -20px 16px 0;
}
.station{
height: 8px;
width: 8px;
border-radius: 50%;
border: 1px solid #000;
display: flex;
justify-content: center;
align-items: center;
}
.station-name {
margin: 0 16px -20px;
white-space: nowrap;
}
<div class="main">
<div class="station">
<span class="station-name">first station</span>
</div>
<div class="line">
<span class="line-name">short line</span>
</div>
<div class="station">
<span class="station-name">loooooong station name</span>
</div>
<div class="line">
<span class="line-name">very very very very loooooooong line name</span>
</div>
<div class="station">
<span class="station-name">this on name</span>
</div>
</div>
我有一系列地铁线路和车站。我要做的是显示line names on the up center of line
,显示station names right below the station
,线路和车站是相连的。
重要的是line names shouldn't exceed line, and shouldn't cover other line names
和station names should also not cover other station names
,无论站名或线路名多长。
现在的问题是站名太长会覆盖其他站名。
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre><code>.main{
margin-top: 32px;
margin-left: 32px;
display: flex;
flex-direction: row;
justify-content: left;
align-items: center;
}
.line{
height: 2px;
min-width: 32px;
border-bottom: 2px solid;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
}
.line-name{
margin: -20px 16px 0;
}
.station{
height: 8px;
width: 8px;
border-radius: 50%;
border: 1px solid #000;
display: flex;
justify-content: center;
align-items: center;
}
.station-name {
margin: 0 16px -20px;
white-space: nowrap;
}
<div class="main">
<div class="station">
<span class="station-name">first station</span>
</div>
<div class="line">
<span class="line-name">short line</span>
</div>
<div class="station">
<span class="station-name">loooooong station name</span>
</div>
<div class="line">
<span class="line-name">very very very very loooooooong line name</span>
</div>
<div class="station">
<span class="station-name">this on name</span>
</div>
</div>