我試圖讓每個條從底部開始,但它們從容器頂部開始。我怎樣才能將它們對齊在容器的底部。我試過`垂直對齊:底部
.phase-balancing-bar-graph-container{
position: relative;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: pink;
height: 100vh;
padding: 20px;
}
.phase-balancing-bar-graph-container .graph-wrapper{
position: absolute;
width: 55%;
display: flex;
justify-content: space-between;
background-color: grey;
height: calc(100% - 65%);
top: 10%;
padding: 0 20px 0 20px
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container{
position: relative;
width: 60px;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar-phase-label{
display: flex;
justify-content: center;
align-items: center;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.a{
background-color: #BA55D3;
transition: 0.5s ease;
height: 25%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.b{
background-color: #FF8C00;
transition: 0.5s ease;
height: 40%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.c{
background-color: #81C784;
transition: 0.5s ease;
height: 70%;
}
<div class="phase-balancing-bar-graph-container">
<div class="graph-wrapper">
<div class="bar-container">
<div class="bar-phase-label">A</div>
<div class="bar a"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">B</div>
<div class="bar b"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">C</div>
<div class="bar c"></div>
</div>
</div>
</div>
` 但它沒有用。不知道我做錯了什么。我嘗試了其他東西,但它不起作用。我已將我的代碼附加到這篇文章中。請運行代碼以了解。謝謝
uj5u.com熱心網友回復:
您需要在 css 中添加此代碼
.phase-balancing-bar-graph-container .graph-wrapper .bar-container {
position: relative;
width: 60px;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.phase-balancing-bar-graph-container {
position: relative;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: pink;
height: 100vh;
padding: 20px;
}
.phase-balancing-bar-graph-container .graph-wrapper {
position: absolute;
width: 55%;
display: flex;
justify-content: space-between;
background-color: grey;
height: calc(100% - 65%);
top: 10%;
padding: 0 20px 0 20px;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container {
position: relative;
width: 60px;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar-phase-label {
display: flex;
justify-content: center;
align-items: center;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.a {
background-color: #ba55d3;
transition: 0.5s ease;
height: 25%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.b {
background-color: #ff8c00;
transition: 0.5s ease;
height: 40%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.c {
background-color: #81c784;
transition: 0.5s ease;
height: 70%;
}
<div class="phase-balancing-bar-graph-container">
<div class="graph-wrapper">
<div class="bar-container">
<div class="bar-phase-label">A</div>
<div class="bar a"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">B</div>
<div class="bar b"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">C</div>
<div class="bar c"></div>
</div>
</div>
</div>
uj5u.com熱心網友回復:
請嘗試此代碼
.phase-balancing-bar-graph-container{
position: relative;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: pink;
height: 100vh;
padding: 20px;
}
.phase-balancing-bar-graph-container .graph-wrapper{
position: absolute;
width: 55%;
display: flex;
justify-content: space-between;
background-color: grey;
height: calc(100% - 65%);
top: 10%;
padding: 0 20px 0 20px
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container{
position: relative;
width: 60px;
display: flex;
flex-direction: column;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar-phase-label{
display: flex;
justify-content: center;
align-items: flex-start;
flex: 1 0 auto;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.a{
background-color: #BA55D3;
transition: 0.5s ease;
height: 25%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.b{
background-color: #FF8C00;
transition: 0.5s ease;
height: 40%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.c{
background-color: #81C784;
transition: 0.5s ease;
height: 70%;
}
<div class="phase-balancing-bar-graph-container">
<div class="graph-wrapper">
<div class="bar-container">
<div class="bar-phase-label">A</div>
<div class="bar a"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">B</div>
<div class="bar b"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">C</div>
<div class="bar c"></div>
</div>
</div>
</div>
uj5u.com熱心網友回復:
嘗試這個:
我用于flex元素。我也從position: absolute; top: 10%;and中洗掉了and 。不需要他們。所以我在邊框底部的距離處使用了填充:position: relative.graph-wrapper.bar-container.graph-wrapper
.phase-balancing-bar-graph-container{
position: relative;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: pink;
height: 100vh;
padding: 20px;
}
.phase-balancing-bar-graph-container .graph-wrapper{
width: 55%;
display: flex;
justify-content: space-between;
background-color: grey;
height: calc(100% - 65%);
padding: 10px 20px; /*here*/
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container{
width: 15%; /*here*/
display: flex; /*here*/
flex-direction: column; /*here*/
justify-content: flex-end; /*here*/
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar-phase-label{
display: flex;
justify-content: center;
align-items: center;
height:30%; /*here*/
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.a{
background-color: #BA55D3;
transition: 0.5s ease;
height: 25%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.b{
background-color: #FF8C00;
transition: 0.5s ease;
height: 40%;
}
.phase-balancing-bar-graph-container .graph-wrapper .bar-container .bar.c{
background-color: #81C784;
transition: 0.5s ease;
height: 70%;
}
<div class="phase-balancing-bar-graph-container">
<div class="graph-wrapper">
<div class="bar-container">
<div class="bar-phase-label">A</div>
<div class="bar a"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">B</div>
<div class="bar b"></div>
</div>
<div class="bar-container">
<div class="bar-phase-label">C</div>
<div class="bar c"></div>
</div>
</div>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/435033.html
上一篇:ChartJS陣列作為一項
