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:

17648 questions
983
votes
41 answers

Better way to set distance between flexbox items

To set the minimal distance between flexbox items I'm using margin: 0 5px on .item and margin: 0 -5px on container. For me it seems like a hack, but I can't find any better way to do this. Example #box { display: flex; width: 100px; …
Sasha Koss
  • 10,348
  • 4
  • 18
  • 24
827
votes
6 answers

In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?

Consider the main axis and cross axis of a flex container:                                                                                                                                                    Source: W3C To align flex items along the…
Michael Benjamin
  • 265,915
  • 79
  • 461
  • 583
798
votes
13 answers

How to Right-align flex item?

Is there a more flexbox-ish way to right-align "Contact" than to use position: absolute? .main { display: flex; } .a, .b, .c { background: #efefef; border: 1px solid #999; } .b { flex: 1; text-align: center; } .c { position: absolute; right: 0;…
Mark Boulder
  • 11,570
  • 11
  • 40
  • 73
776
votes
13 answers

Flexbox: center horizontally and vertically

How to center div horizontally, and vertically within the container using flexbox. In below example, I want each number below each other (in rows), which are centered horizontally. .flex-container { padding: 0; margin: 0; list-style:…
bsr
  • 52,180
  • 78
  • 198
  • 296
580
votes
11 answers

How can I make Flexbox children 100% height of their parent?

I'm trying to fill the vertical space of a flex item inside a Flexbox. .container { height: 200px; width: 500px; display: flex; flex-direction: row; } .flex-1 { width: 100px; background-color: blue; } .flex-2 { position:…
Raz
  • 6,249
  • 4
  • 17
  • 17
500
votes
10 answers

How to vertically align text inside a flexbox?

I would like to use flexbox to vertically align some content inside an
  • but not having great success. I've checked online and many of the tutorials actually use a wrapper div which gets the align-items:center from the flex settings on the…
  • styler
    • 13,569
    • 20
    • 73
    • 127
    496
    votes
    8 answers

    Align an element to bottom with flexbox

    I have a div with some children:

    heading 1

    heading 2

    Some more or less text

    Click me
    and I want the following layout: ------------------- |heading 1 …
    supersize
    • 10,844
    • 14
    • 56
    • 108
    481
    votes
    23 answers

    How do I keep two side-by-side divs the same height?

    I have two divs side by side. I'd like the height of them to be the same, and stay the same if one of them resizes. I can't figure this one out though. Ideas? To clarify my confusing question, I'd like both boxes to always be the same size, so if…
    NibblyPig
    • 46,891
    • 62
    • 180
    • 311
    449
    votes
    32 answers

    Flex-box: Align last row to grid

    I have a simple flex-box layout with a container like: .grid { display: flex; flex-flow: row wrap; justify-content: space-between; } Now I want the items in the last row to be aligned with the other. justify-content: space-between; should be…
    Thorben Croisé
    • 10,192
    • 8
    • 35
    • 47
    448
    votes
    11 answers

    What's the difference between align-content and align-items?

    Can anybody show me the difference between align-items and align-content?
    Dinh
    • 4,611
    • 3
    • 10
    • 3
    443
    votes
    2 answers

    Flexbox not giving equal width to elements

    Attempting a flexbox nav that has up to 5 items and as little as 3, but it's not dividing the width equally between all the elements. Fiddle The tutorial I'm modeling this after is…
    itsclarke
    • 7,496
    • 6
    • 29
    • 42
    420
    votes
    19 answers

    How to align 3 divs (left/center/right) inside another div?

    I want to have 3 divs aligned inside a container div, something like this: [[LEFT] [CENTER] [RIGHT]] Container div is 100% wide (no set width), and center div should remain in center after resizing the container. So I…
    serg
    • 103,023
    • 70
    • 299
    • 324
    410
    votes
    23 answers

    Bootstrap 4 align navbar items to the right

    How do I align a navbar item to right? I want to have the login and register to the right. But everything I try does not seem to work. This is what I have tried so far:
    around the
    403
    votes
    9 answers

    What's the difference between display:inline-flex and display:flex?

    I am trying to vertically align elements within an ID wrapper. I gave the property display:inline-flex; to this ID as the ID wrapper is the flex container. But there is no difference in presentation. I expected that everything in the wrapper ID…
    astridx
    • 4,685
    • 2
    • 12
    • 25
    396
    votes
    15 answers

    Vertical Align Center in Bootstrap

    I am trying to center my Container in the middle of the page using Bootstrap 4. I have been unsuccessful thus far. Any help would be appreciated. I have built it at Codepen.io so you guys can play with it and let me know what works as I am about out…
    canaan seaton
    • 5,684
    • 3
    • 14
    • 20
    1
    2 3
    99 100