John Smith
John Smith

Reputation: 4363

Horizontal list: inline-block vs flex

horizontal list screenshot

Given a horizontal list, what is the practical difference between:

and

I have tested it on different sizes and haven't noticed any differences, but perhaps there are some more subtle implications, especially how the child elements resize?

Upvotes: 3

Views: 521

Answers (2)

mahmood sharifi
mahmood sharifi

Reputation: 21

By setting display to inline-block each child get margin-right of 4px by default and default alignment would be by content. but after changing defaults they can be similar, i think you should decide by how you want to change the component in different situations, like in mobile or if you want to change it a little to use somewhere else. I personally recommend using flexbox, because its easier to maintain.

Upvotes: 0

Johannes
Johannes

Reputation: 67778

display:flex; provides some more options concerning the alignment of the items both horizontally and vertically, and also concerning the adaption of their size: shrinking or growing in the flex-direction and aligning their size in the cross-axis direction. inline-blocks simply line up horizontally, keeping their original width and height, and align vertically according to their vertical-align parameter setting.

Upvotes: 3

Related Questions