Questions tagged [flexbox]

CSS module for flexible layouts providing a broad range of options for aligning elements while eliminating the need for floats and tables.

In the flex layout model, the children of a flex container can be laid out in any direction, in any order (independent of source order), and can "flex" their sizes, either growing to fill unused space or shrinking to avoid overflowing the parent. Both horizontal and vertical alignment of the children can be easily manipulated. Nesting of these boxes (horizontal inside vertical, or vertical inside horizontal) can be used to build layouts in two dimensions.


Flexbox Specification


Modern Flexbox Articles

Articles

Browser Support Information

Canonical Questions & Answers:

21882 questions
217
votes
4 answers

Making a flex item float right

I have a
Ignore parent?
another child
The parent has .parent { display: flex; } For my first child, I want to simply float the item to the…
Zhen Liu
  • 7,550
  • 14
  • 53
  • 96
197
votes
13 answers

Text in a flex container doesn't wrap in IE11

Consider the following snippet: .parent { display: flex; flex-direction: column; width: 400px; border: 1px solid red; align-items: center; } .child { border: 1px solid blue; }
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
193
votes
5 answers

How to align flexbox columns left and right?

With typical CSS I could float one of two columns left and another right with some gutter space in-between. How would I do that with flexbox? http://jsfiddle.net/1sp9jd32/ #container { width: 500px; border: solid 1px #000; display:…
archytect
  • 3,615
  • 5
  • 22
  • 30
190
votes
16 answers

Equal height rows in a flex container

As you can see, the list-items in the first row have same height. But items in the second row have different heights. I want all items to have a uniform height. Is there any way to achieve this without giving fixed-height and only using…
Jinu Kurian
  • 9,128
  • 3
  • 27
  • 35
189
votes
2 answers

Prevent flex items from stretching

Sample: div { display: flex; height: 200px; background: tan; } span { background: red; }
This is some text.
I have two questions, please: Why does it basically happen to the span? What is the right…
Mori
  • 8,137
  • 19
  • 63
  • 91
174
votes
4 answers

How can I make my flexbox layout take 100% vertical space?

How can I tell a flexbox layout row consume the remaining vertical space in a browser window? I have a 3-row flexbox layout. The first two rows are fixed height, but the 3rd is dynamic and I would like it to grow to the full height of the…
Nicholas Pappas
  • 10,439
  • 12
  • 54
  • 87
162
votes
3 answers

How can I combine flexbox and vertical scroll in a full-height app?

I want to use a full-height app using flexbox. I found what I want using old flexbox layout module (display: box; and other things) in this link: CSS3 Flexbox full-height app and overflow This is a correct solution for browsers that only support the…
José Cabo
  • 6,149
  • 3
  • 28
  • 39
161
votes
3 answers

Flexbox vs Twitter Bootstrap (or similar framework)

I have recently discovered Flexbox when I was looking for a solution to make divs the same hight, depending on the highest one. I have read the following page on CSS-tricks.com and it convinced me that flexbox is a very powerful module to learn and…
Rvervuurt
  • 8,589
  • 8
  • 39
  • 62
158
votes
8 answers

React Native absolute positioning horizontal centre

It seems that with position:absolute in use an element cannot be centred using justifyContent or alignItems. There's a workaround to use marginLeft but does not display the same for all devices even using dimensions to detect height and width of…
Hasen
  • 11,710
  • 23
  • 77
  • 135
152
votes
1 answer

Difference between justify-content vs align-items?

I'm having a really hard time understanding what's the difference? From my research it seems like justify-content can do... space-between and space-around, while align-items can do... stretch, baseline, initial and inherit? Also looks like both…
Ben Casalino
  • 2,262
  • 5
  • 20
  • 28
152
votes
2 answers

How to make a flex item not fill the height of the flex container?

As you can see in the code below, the left div inside the flex container stretches to meet the height of the right div. Is there an attribute I can set to make its height the minimum required for holding its content (like usual height: auto divs…
user81993
  • 6,167
  • 6
  • 32
  • 64
148
votes
9 answers

How to center a flex container but left-align flex items

I want the flex items to be centered but when we have a second line, to have 5 (from image below) under 1 and not centered in the parent. Here's an example of what I have: ul { display: flex; flex-direction: row; flex-wrap: wrap; …
Etienne Noël
  • 5,988
  • 6
  • 48
  • 75
148
votes
10 answers

Auto Resize Image in CSS FlexBox Layout and keeping Aspect Ratio?

I've used the CSS flex box layout which appears as shown below: If the screen gets smaller it turns into this: The problem is that the images are not resized keeping the aspect ration from the original image. Is it possible to use pure CSS and…
Michael
  • 32,527
  • 49
  • 210
  • 370
147
votes
9 answers

Prevent flexbox shrinking

I'm using flexbox to layout a page because the growing behavior is useful. But I'd like to completely prevent the shrinking behavior. Anyway to manage this? Example code:
This…
Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134
146
votes
8 answers

Width ignored on flexbox items

http://jsfiddle.net/XW9Se/ I've set width: 200px; on the left
but if I view it with the browser inspector tool it appears that the real width is random or something. It keeps changing depending on the window size. Why doesn't the width take…
Alex
  • 66,732
  • 177
  • 439
  • 641