I have an Angular app and I am displaying different strings on top of one another within a <div>
, however I am wanting them to be justified to the width of the div.
- Shorter strings should have larger font-size in order to fill the space, not simply adding white space between the letters.
- Long strings should have smaller font size & should not wrap onto the next line.
This is a visual representation of what I am after:
I have seen this link showing different methods of doing something like this, but I just cannot get it to work...
Forgot to add code. Here you go.
component.ts
export class FitTextComponent implements OnInit {
line1 = 'this is text for line 1';
line2 = 'less text';
line3 = 'medium amount of text';
line4 = 'this will be a really long line';
text = [this.line1, this.line2, this.line3, this.line4];
constructor() { }
ngOnInit() {
}
}
component.html
<div class="container">
<p *ngFor="let line of text">{{line}}</p>
</div>
component.css
.container {
width: 300px;
background: grey;
}