Inline Flex Container (display: Inline-flex) Is Expanding The Full Width Of Parent Container
Solution 1:
Use width: 350px
instead of flex-basis: 350px
.
In your code, .row
is first sized summing the width
of its contents. Since .infos
has no width
, its initial size is given by its very long content. So .row
fills all the available space in its containing block. It's after the size of .row
has been determined that the flex items do flex and .infos
becomes 350px
. But then it's too late, .row
is already too wide.
If you use width: 350px
, .row
will be sized using that value, without taking extra space.
.out {
border: 1px solid red;
display: block;
position: fixed;
top: 0;
left: 0;
}
.row {
display: inline-flex;
flex-direction: row;
padding: 10px;
border: 1px solid yellow;
}
.infos {
border: 1px solid green;
width: 350px;
}
.dynamic {
border: 1px solid blue;
flex: 11;
}
<divclass="out"><divclass="row"><divclass="infos">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit a
</div><divclass="dynamic">
Lorem ipsum
</div></div></div>
Solution 2:
If i understand right, margin
or align-self
should do it:
align-self
https://jsfiddle.net/2ymx9oog/1/
.out {
border: 1px solid red;
display: block;
position: fixed;
top: 0;
left: 0;
}
.row {
display: inline-flex;
flex-direction: row;
padding: 10px;
border: 1px solid yellow;
}
.infos {
border: 1px solid green;
flex-basis: 350px;
}
.dynamic {
border: 1px solid blue;
flex: 11;
align-self:flex-start
}
<divclass="out"><divclass="row"><divclass="infos">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit a
</div><divclass="dynamic">
Lorem ipsum
</div></div></div>
margin-bottom
in this case https://jsfiddle.net/2ymx9oog/2/
.out {
border: 1px solid red;
display: block;
position: fixed;
top: 0;
left: 0;
}
.row {
display: inline-flex;
flex-direction: row;
padding: 10px;
border: 1px solid yellow;
}
.infos {
border: 1px solid green;
flex-basis: 350px;
}
.dynamic {
border: 1px solid blue;
flex: 11;
margin-bottom: auto
}
<divclass="out"><divclass="row"><divclass="infos">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit a
</div><divclass="dynamic">
Lorem ipsum
</div></div></div>
if it is about the width too, then remove the flex property : https://jsfiddle.net/2ymx9oog/4/
For both earlier example see results here :
margin
https://jsfiddle.net/2ymx9oog/3/align-self
https://jsfiddle.net/2ymx9oog/5/
You can play with margin or align-self
example with margin:auto without flex values set https://jsfiddle.net/2ymx9oog/6/ set your dynamic box in the middle within the right area
You may set it at middle top, at middle middle, middle bottom, left top, left bottom, left middle, and so on
Post a Comment for "Inline Flex Container (display: Inline-flex) Is Expanding The Full Width Of Parent Container"