How can I simulate the display: box
with display: flex
? It’s seems that the box
is abandoned, but I need render the element inline.
The flex
will override the layout with it’s own rule row
or column
. So the tag in flex
container won’t be rendered inline.
EDIT:
What I do is writing an user script for a page. I don’t want to modify the parent of my element inserted. Otherwise I have to fit every page that parent is display: flex
by myself.
EDIT2:
I don’t want to change the struct of text nodes<a href></a>text nodes
#container {
display: flex;
width: 100px;
}
#box {
display: -webkit-box;
width: 100px;
}
#a {
display: inline-flex;
}
#tag {
display: flex;
}
`display: flex`
<p id="container">
<span id="tag">[TAG]</span> Hello world and <a id="a" href="/">StackOverflow</a>! Show me the money
</p>
Expected: `display: -webkit-box`
<p id="box">
<span id="tag">[TAG]</span> Hello world and <a id="a" href="/">StackOverflow</a>! Show me the money
</p>
`display: block` is fine. But it will failed when tag display as flex(`inline-flex` is fine)
<p id="container" style="display: block">
<span id="tag">[TAG]</span> Hello world and <a id="a" href="/">StackOverflow</a>! Show me the money
</p>
3
Answers
You can simply assign a width to the message.
Add another flex-box and set
flex-direction: column;
.you can do it with CSS grid: