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
86
votes
9 answers

react-native - Fit Image in containing View, not the whole screen size

I'm trying to fit images in their containing views so that I can have a seamless grid of images. The problem is that resizeMode='contain' seems to fit to the width of the screen or at least some higher level container, I need the images to fit to…
BarakChamo
  • 3,321
  • 5
  • 30
  • 38
85
votes
7 answers

React native, children of ScrollView wont fill full height

So I have a horizontal scrollview at the top of the view. The ScrollView contains nodes that have a specified width. I then have a border on the bottom of the ScrollView, like you can see in this screen cap: https://i.stack.imgur.com/zcvDj.png As…
agmcleod
  • 13,321
  • 13
  • 57
  • 96
85
votes
5 answers

Is it possible for flex items to align tightly to the items above them?

This is, in effect, the Pinterest layout. However, the solutions found online are wrapped in columns, which means the container inadvertently grows horizontally. That is not the Pinterest layout, and it does not work well with dynamically-loaded…
Guybrush Threepwood
  • 1,253
  • 1
  • 11
  • 21
84
votes
1 answer

Prevent a child element from overflowing its parent in flexbox

I'm working on a web app that shows a large grid of cards, the height of which is inherently variable. In the interests of aesthetics, we were using jQuery's .matchHeight() to equalise the height of cards within each row. The performance of that…
Chris
  • 3,445
  • 3
  • 22
  • 28
84
votes
9 answers

Spacing between flexbox items

This is what I want: But this is the closest I've got: body{ margin: 0; padding: 0; border: 1px solid red; } .flex{ display: -ms-flexbox; display: -webkit-box; display: -webkit-flexbox; display: -webkit-flex; …
nice ass
  • 16,471
  • 7
  • 50
  • 89
83
votes
9 answers

How to center elements on the last row in CSS Grid?

I am using CSS grid to layout some items like this... #container { display: grid; grid-template-columns: 16.666% 16.666% 16.666% 16.666% 16.666% 16.666%; } .item { background: teal; color: white; padding: 20px; margin:…
fightstarr20
  • 11,682
  • 40
  • 154
  • 278
83
votes
3 answers

Flexbox code working on all browsers except Safari. Why?

Grid columns with list tags, I need to display in correct order per every 3 columns, with auto width enabled for every extra HTML list elements. This is my example: