shlogg · Early preview
Jen C. @yujhenchen

Difference Between Inline-Flex And Flex In CSS Layout

inline-flex` doesn't automatically fill parent container like `flex`. Its size depends on content & additional styles applied. `flex` behaves like block-level element, expanding to fit parent's available width by default.

inline-flex

A child container with display: inline-flex does not automatically fill the parent container. Its size depends on its content and any additional styles applied to it.

  
  
  flex

A child container with display: flex automatically fills the parent container's width because flex behaves like a block-level element, which expands to fit the parent's available width by default.

  
  
  Example

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="src...