I would like to set the width of the div, and it's content by the width of one of the paragraphs in it. This is the html structure:
<div class="panel">
<p class="user-title">Date 08.03.2018 User: Joe Doe</p>
<div>
<p>Some long text in the paragraph that is wider than the title above it</p>
<p>Another shorter text</p>
</div>
Currently I have the styling set up like this for the .panel
:
.panel {
width: 20rem;
display: flex;
flex-direction: column;
flex: 0 1 270px;
}
The problem I have is that the text inside the paragraph tags with the class .user-title
, breaks to another line in Chrome, and Edge, and not in IE. I would like to keep the text in the same line, and that everything else takes the width of that text.
I have tried with setting the .panel
to:
width: auto;
height: auto;
display: inline-flex;
flex-direction: column;
flex: 0 1 auto;
position: relative;
And the child div to:
position: absolute;
width: 100%;
top: 30px;
Then, the .panel
and the child div
, take the width of the paragraph
inside of it. But, the child element goes out of the bounderis of the panel element in it's height, the panel is not covering the height of both the paragraph and the child div.
This is the fiddle. How can I fix that?