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
108
votes
7 answers

input / button elements not shrinking in a flex container

When using input and button elements inside a flex container, the flex and/or flex-grow properties don't seem to do anything. Code that demonstrates my issue. button, input { font-size: 1rem; } button { border: none; …
viderizer
  • 1,125
  • 2
  • 7
  • 7
106
votes
5 answers

Simulate display: inline in React Native

React Native doesn't support the CSS display property, and by default all elements use the behavior of display: flex (no inline-flex either). Most non-flex layouts can be simulated with flex properties, but I'm flustered with inline text. My app has…
Brent Traut
  • 5,614
  • 6
  • 29
  • 54
105
votes
14 answers

Make an item stick to the bottom using flex in react-native

Suppose this is the layout: ... ... ... ...
Karl
  • 1,689
  • 3
  • 15
  • 23
105
votes
6 answers

How to get flexbox to include padding in calculations?

Below are two rows. First row is two items at flex 1 and one at flex 2. Second Row is two items at flex 1. According to the spec 1A + 1B = 2A But when padding is included in the calculation the sum is incorrect as you can see in the example…
DreamTeK
  • 32,537
  • 27
  • 112
  • 171
103
votes
5 answers

Giving wrapped flexbox items vertical spacing

I've recently been playing with Flexbox for the first time and, in general, it's absolutely amazing. I've encountered an issue recently however, where I cannot seem to give flex items that are wrapping any vertical spacing. I've tried…
lordchancellor
  • 3,847
  • 4
  • 26
  • 26
103
votes
3 answers

Flex / Grid layouts not working on button or fieldset elements

I'm trying to center inner elements of a
Ingemar
  • 1,638
  • 2
  • 12
  • 15
103
votes
1 answer

Height 100% on flexbox column child

I'm having troubles with a flexbox column in that children of the flex'd element don't respond to height in percentages. I've only checked this in Chrome, and from what I understand it's a Chrome only problem. Here's my example: HTML
CourtDemone
  • 5,772
  • 6
  • 23
  • 25
102
votes
9 answers

How can I have a position: fixed; behaviour for a flexbox sized element?

I have a div called .side-el which I would like to have in a position: fixed; behavior, but as soon as I apply position fixed the width alternates from the right one. The right width would be the one set by flexbox. How can I achieve this…
Daniel Schmidt
  • 11,605
  • 5
  • 38
  • 70
101
votes
2 answers

How does flex-wrap work with align-self, align-items and align-content?

align-self In the following code, align-self works with flex-wrap: nowrap. flex-container { display: flex; flex-wrap: nowrap; align-content: flex-start; width: 250px; height: 250px; background-color: silver; } flex-item { …
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
100
votes
7 answers

How to use zIndex in react-native

I've want to achieve the following: The following images are what I can do right now, but that's NOT what I want. Sample of code I have right now: renderA() { return ( // parent of A …
SudoPlz
  • 20,996
  • 12
  • 82
  • 123
98
votes
1 answer

flexbox justify-self: flex-end not working?

I have a layout where sometimes the 'left' item is missing. In such cases, I still want the 'right' item to be right-aligned. I thought I could do this with justify-self but that doesn't appear to be the case. Is there a flexbox property for…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
98
votes
6 answers

How to align left last row/line in multiple line flexbox

I have a major issue with flexbox layout. I build a container with a boxes filled with images, and i decided to use flexbox layout to justify the content to make it looks like a grid Her's the code:
PuZ
  • 983
  • 1
  • 7
  • 5
97
votes
5 answers

Margin collapsing in flexbox

Typically, in CSS, when a parent and its last child have a margin, the margins collapse to create a single margin. E.g. article { margin-bottom: 20px } main { background: pink; margin-bottom: 20px; } footer { background:…
Coffee Bite
  • 4,956
  • 5
  • 33
  • 38
96
votes
4 answers

How to disable equal height columns in Flexbox?

I have three elements I'm trying to align in my layout. First, I have a div for feedback, and then a search input, and then a div element for suggestions. I want the first and last element to have a width of 20%, and the search input to have a width…
Peter Boomsma
  • 8,851
  • 16
  • 93
  • 185
94
votes
3 answers

CSS flex, how to display one item on first line and two on the next line

This is a pretty simple question, I guess, but I can't get 3 items in the flex container to display in 2 rows, one in the first row and the other 2 in the second row. This is the CSS for the flex container. It displays the 3 items on a single line,…
RoyS
  • 1,439
  • 2
  • 14
  • 21