I have a container with a fixed with. In this container there will be some text with a variable length. What I am trying to do is do automatically adjust the font-size of the text such that the it will fit into the container.
What is the best way to do that?
I have already tried to set the font-size with vm
but this only resizes the text, when the container gets smaller and not when the text gets longer.
More precise my html and css look as follows and the text in label
should resize if it is longer, to fit inot the label.
.input-wrapper {
display: flex;
flex-direction: row;
width: 70%;
}
label {
color: white;
display: flex;
flex-wrap: wrap;
width: max-content;
background-color: var(--violet);
min-width: 30%;
justify-content: center;
align-items: center;
word-wrap: break-word;
}
input {
display: flex;
border: 1px solid var(--violet);
min-width: 70%;
}
<form onSubmit={this.handleSubmit}>
<div className="input-wrapper">
<label id="fixed">Gas cost</label>
<input type="text"/>
</div>
</form>