How can I extend the background to the right using flexbox and a container with limited width?
The spans are the tags that must contain a background-color, not the parent tags. (Because the color can be different for each span)
I know that display table
and table-row
fixes it, but it gives me another problems with paddings and borders, so I would like to use flexbox
model.
There is another requeriment, the background should extend to the widest span, so all spans should have the same width and extend the background to the same position.
pre {
width: 300px;
}
code {
display: flex;
flex-direction: column;
overflow: auto;
}
span {
background-color: #ddd;
}
<pre>
<code>
<span>sadfasdsad asd adsads das ads dasdasdas dasd as das</span>
<span>sadfdas das adsdsad sa dasda s adsasdsad asd adsads das ads dasdas</span>
</code>
</pre>