I have the flex-container with column direction info__text-container whose width is 150px. Inside I have two spans with text that can be wrapped to next line.
What I want is flex item shrink to content when text wraps, but it always remains 150px.
Words are generated dynamically, so I can't just use <br/>
or smth.
What I have
What I want
body {
font-family: sans-serif;
}
.info {
display: flex;
align-items: center;
}
.info__block-margin {
margin-right: 48px;
}
.info__number {
font-size: 40px;
}
.info__number-margin {
margin-right: 20px;
}
.info__text-container {
display: flex;
flex-direction: column;
max-width: 150px;
}
.info__text {
min-width: 0;
font-size: 16px;
font-weight: bold;
line-height: 25px;
}
.info__subtext {
min-width: 0;
font-size: 14px;
}
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app"></div>
<div class="info info__block-margin">
<p class="info__text-container">
<span class="info__text">Socially SignificantSo </span>
<span class="info__subtext">Socially SignificantSocial</span>
</p>
<span class="info__number">98</span>
</div>
<script src="src/index.js"></script>
</body>
</html>
Thank you in advance.
` in between your words then you will get what you want or set a fixed width for that block – Huangism Jan 30 '20 at 17:53