Home > OS >  HTML-CSS DIV Element Not Starting From Bottom of Container
HTML-CSS DIV Element Not Starting From Bottom of Container

Time:03-01

I am trying to have each bar begin from the bottom but they begin from the top of the container. How can I align them at the bottom of the container. I tried `vertical-align: bottom

.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 >
  <div >
    <div >
      <div >A</div>
      <div ></div>
    </div>
    <div >
      <div >B</div>
      <div ></div>
    </div>
    <div >
      <div >C</div>
      <div ></div>
    </div>
  </div>
</div>

` but it didnt work. Not sure what I am doing wrong. I have tried other stuff but it isn't working. I have attached my code to this post. Please run code to understand. Thank you

CodePudding user response:

you need to add this code in 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 >
  <div >
    <div >
      <div >A</div>
      <div ></div>
    </div>
    <div >
      <div >B</div>
      <div ></div>
    </div>
    <div >
      <div >C</div>
      <div ></div>
    </div>
  </div>
</div>

CodePudding user response:

Please try this code

.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 >
  <div >
    <div >
      <div >A</div>
      <div ></div>
    </div>
    <div >
      <div >B</div>
      <div ></div>
    </div>
    <div >
      <div >C</div>
      <div ></div>
    </div>
  </div>
</div>

  • Related