0
我想調整日期和時間以與城市名稱相同。請看下面的圖片。藍色路線不從城市名稱的開始處開始,因爲.flight-date
元素移至下一行。我如何才能使date-time
元素增長到頂部而不是底部或者提出任何其他解決方案我如何才能實現類似的結果?Bootstrap列內容顯示對齊頂部
HTML:
<div class="container-fluid">
<div class="roundtrip">
<div class="trip col-xs-5">Outbound
<div class="flight">
<div class="date-time col-xs-offset-4 col-xs-1">
<div class="flight-time pull-right">12:40</div>
<div class="flight-date pull-right">Friday 11 Sep</div>
</div>
<div class="col-xs-offset-0 col-xs-2">
Los Angeles
</div>
</div>
<div class="flight-path"></div>
<div class="flight">Chicago</div>
<div class="connection">5hr wait</div>
<div class="flight">Chicago</div>
<div class="flight-path"></div>
<div class="flight">New York</div>
<div class="connection">2hr wait</div>
<div class="flight">New York</div>
<div class="flight-path"></div>
<div class="flight">Amsterdam</div>
</div>
<!-- just padding: --><div class="col-xs-2"></div>
<div class="trip col-xs-5">Inbound
<div class="flight">Amsterdam</div>
<div class="flight-path"></div>
<div class="flight">Los Angeles</div>
</div>
</div>
</div>
LESS:
body {padding: 2em 0 0 2em}
.roundtrip {
width: 100%;
display: inline-flex;
flex-direction: row;
align-items: stretch;
}
.trip {
//width: 100px;
text-align: center;
border: 1px solid black;
//margin: 0px 3px;
display: flex;
flex-direction: column;
}
.flight {
white-space: nowrap;
}
.date-time{
vertical-align:top
}
.flight-path {
width: 6px;
min-height: 85px;
flex-grow: 1;
align-self: center;
background-color: #6090FF;
}
.connection {
height: 40px;
align-self: center;
width: 70px;
color: red;
border: 1px solid red;
display: flex;
flex-direction: column;
justify-content: center;
}
謝謝!只需要一個額外的問題,我如何讓日期元素中間的'12:30'對齊'9月11日星期五?再次感謝! –
我很高興幫助你,事情是你有'class =「date-time col-xs-offset-4 col-xs-1」'在容器上,所以它的寬度是這樣的:將它改爲'date-time col-xs-offset-2 col-xs-3',將它設置爲'text-align:center'並刪除類'pull-right'形式'flight-time'和'flight-date ' –
我編輯答案將其居中。 –