1

I would align a text with mat-progress-bar component.

<div>
  <span class="text">{{ element.progress }}</span>
  <span>
    <mat-progress-bar mode="determinate" [value]="element.progress"></mat-progress-bar>
  </span>
</div>

Even after using inline-block as CSS property progress bar stay under the texte.

How can I align the two elements in the same line without reducing mat-progress-bar width (keep it at 100% ) ?

Stackblitz

infodev
  • 4,673
  • 17
  • 65
  • 138

3 Answers3

2

take a look at my solution, hope it works for you.

/** No CSS for this example */
.text {
  display: inline-block;
  width: 40px;
}
mat-progress-bar {
  display: inline-block;
  width: calc(100% - 40px);
  margin-bottom: 4px;
}
MilosMarkoni
  • 171
  • 8
1

You need to use the solution from the How to overlay one div over another div and Vertically centering a div inside another div articles to achieve this behavior. These articles describe why you need them well.

<div class="container">
    <span class="text">{{ element.progress }}</span>
  <mat-progress-bar mode="determinate" [value]="element.progress"></mat-progress-bar>
</div>
.container {
  position:relative;
  display:flex;
  justify-content:center;
  align-items:center;
}

.text {
  position: absolute;
  z-index: 1;
}

mat-progress-bar {
  position: absolute;
}

Stackblitz.

Gosha_Fighten
  • 3,838
  • 1
  • 20
  • 31
1

You can also use the flex-layout library:

<div fxLayout="row" fxLayoutGap="15px" fxLayoutAlign="start center" >
  <span class="text">{{ element.progress }}</span>
  <mat-progress-bar fxFlex mode="determinate" [value]="element.progress"></mat-progress-bar>
</div>

enter image description here

StackBlitz

Documentation: Demo & Info

Quentin
  • 1,865
  • 2
  • 24
  • 40