Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsFlexbox is a CSS layout method for arranging interface elements along one axis at a time. Set display: flex on a parent, choose whether its main axis is a row or column, then control sizing, spacing, alignment, and wrapping with a small set of properties.
What Flexbox does
The CSS flexible box layout module is a box model optimized for user-interface design and for laying out items in one dimension. A flex layout can flow horizontally or vertically, but it does not coordinate rows and columns as a single two-dimensional grid.
The element with display: flex is the flex container. Its direct children become flex items; grandchildren are not flex items unless another flex container is applied to their parent.
.toolbar {
display: flex;
}
<nav class="toolbar">
<a href="/home">Home</a>
<a href="/docs">Docs</a>
<button>Sign in</button>
</nav>
With the default direction, these three children are laid out in a row. Their sizes and positions can change as the available space changes.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Understand the main and cross axes
Flexbox properties make sense only after you identify the current axes. flex-direction sets the main axis. The cross axis runs perpendicular to it.
flex-direction |
Main axis | Cross axis |
|---|---|---|
row (default) |
Inline direction, usually left to right in a left-to-right language | Block direction, usually top to bottom |
row-reverse |
Inline direction in reverse order | Block direction |
column |
Block direction, usually top to bottom | Inline direction |
column-reverse |
Block direction in reverse order | Inline direction |
“Horizontal” and “vertical” are less reliable descriptions than main and cross axis because writing modes and direction settings can change how those axes map to the screen.
.stack {
display: flex;
flex-direction: column;
}
Changing a container from row to column also changes which direction the alignment properties control.
Place items with alignment and distribution
justify-content: distribute along the main axis
justify-content positions flex items along the main axis after their sizes have been resolved. Common values include:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
flex-startandflex-endplace items at the start or end.centergroups items in the available space.space-betweenputs equal space between items, with no space at the two outer edges.space-aroundgives each item equal surrounding space, so the outer edges receive half-sized gaps.space-evenlymakes the gaps, including the two outer gaps, equal.
.toolbar {
display: flex;
justify-content: space-between;
}
align-items: align on the cross axis
align-items controls how items are aligned against one another on the cross axis. The default is stretch, which can stretch auto-sized items in the cross direction. Other frequent values are flex-start, flex-end, center, and baseline.
.toolbar {
display: flex;
align-items: center;
}
For a row, justify-content usually affects the horizontal direction and align-items the vertical direction. For a column, those roles switch. Always check flex-direction before diagnosing an alignment that appears to operate in the “wrong” direction.
Align one item or several lines
align-self overrides align-items for one flex item. When wrapping creates multiple lines, align-content distributes the lines within the container’s cross-axis space; it does not replace align-items for items within each line.
Control item sizes with flex-basis, grow, and shrink
Flexbox resolves sizes along the main axis using three related controls:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
flex-basissupplies an item’s starting main-axis size before free space is distributed. It can be a length, percentage, orauto.flex-growdetermines how an item receives positive free space after the basis sizes are accounted for. A grow factor of2receives twice the share of an item with a factor of1, subject to the other sizing rules.flex-shrinkdetermines how an item gives up space when the basis sizes do not fit. Shrinking is affected by the item’s basis and can stop at minimum-content or other minimum-size constraints.
.sidebar {
flex: 0 1 16rem;
}
.content {
flex: 1 1 auto;
}
The flex shorthand combines grow, shrink, and basis in that order: flex: <grow> <shrink> <basis>. For example, flex: 1 1 20rem starts at 20rem, can grow into extra space, and can shrink when necessary. A declaration such as flex: 1 is shorthand, not a universal “make this equal” command: its omitted components are filled in by the shorthand’s rules, so inspect the resulting basis and shrink behavior when exact sizing matters.
Images, long unbroken strings, and intrinsic minimum sizes can prevent an item from shrinking as far as expected. If a flexible child refuses to narrow, check its basis, flex-shrink, and minimum-size constraints; in some layouts, min-width: 0 on a row child is needed to permit its content to shrink within the available width.
Allow items to wrap onto multiple lines
Flex containers use flex-wrap: nowrap by default, so items stay on one line and may shrink to fit. Enable wrapping when a row should form additional lines:
.card-list {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
.card {
flex: 1 1 16rem;
}
With flex-wrap: wrap, items move to a new line when the current line cannot accommodate them. Each line resolves and distributes its free space independently. Consequently, cards on one line can have different widths from cards on another line; wrapped Flexbox does not create shared columns across all lines.
Recommended Free Tools
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
The gap property adds consistent row and column gaps without adding margins to the outer edges. Use row-gap and column-gap when the two directions need different spacing.
Choose Flexbox or Grid
Neither layout system is universally better. Choose based on whether the design is fundamentally one-dimensional or two-dimensional.
| Question | Flexbox | Grid |
|---|---|---|
| How many axes are coordinated? | One main axis at a time, with a perpendicular cross axis for alignment. | Rows and columns are coordinated together as explicit or implicit tracks. |
| How does content flow? | Items flow in a row or column and can wrap naturally. | Items occupy grid areas or tracks, with placement controlled across both dimensions. |
| When is it a natural fit? | Navigation bars, toolbars, button groups, media objects, and a single row or column of components. | Page regions, dashboards, galleries, and layouts where column widths or row alignment must remain coordinated. |
| What happens when content wraps? | Each flex line distributes space independently; columns do not align across lines. | Shared tracks can keep items aligned across multiple rows and columns. |
Use Flexbox for a collection whose primary relationship is along one direction. Use Grid when the relationship between both rows and columns is part of the design. A wrapped Flexbox list can still be the right choice when independent lines are acceptable; switch to Grid when cross-line column alignment is essential.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.A practical Flexbox workflow
- Identify the container. Apply
display: flexto the parent whose direct children should participate in the layout. - Set the main axis. Keep the default
rowfor a row, or usecolumnfor a vertical stack. Use the reverse values only when reversed visual order is intentional. - Decide whether one line is enough. Keep
nowrapwhen items must remain together; setwrapwhen they should form additional lines. - Set item starting sizes. Use
flex-basisor the three-valueflexshorthand for the intended starting size. - Distribute extra or insufficient space. Adjust
flex-growfor extra space andflex-shrinkfor a deficit. Check minimum-size constraints if content overflows. - Align the result. Use
justify-contenton the main axis andalign-itemson the cross axis. If there are multiple wrapped lines, consideralign-content. - Test the narrowest realistic width. Confirm that text, controls, images, and focus indicators remain usable rather than assuming the desktop row will always fit.
Common Flexbox problems and fixes
Everything stays on one line
This is the default behavior. Add flex-wrap: wrap to the container and provide sensible item bases if line breaks are expected.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Items become unexpectedly narrow
Items may be shrinking to resolve a main-axis deficit. Inspect their computed flex-basis, flex-shrink, and minimum-content sizing. Give an item a more suitable basis, set flex-shrink: 0 when it must not shrink, or allow its content box to shrink with an appropriate minimum size.
Alignment changes after switching direction
Changing flex-direction changes the main and cross axes. Re-evaluate justify-content and align-items against those axes instead of swapping properties by trial and error.
Wrapped columns do not line up
That is expected: every flex line distributes its own space. Use Grid when items in separate lines need shared column tracks.
Browser support and specifications
MDN marks the flex shorthand as widely available across browsers since September 2015, while noting that not every part of the latest Flexbox-related syntax is implemented everywhere. Check the MDN compatibility table for a particular property or value against your project’s browser targets. The normative reference is the CSS Flexible Box Layout Module Level 1, a W3C Recommendation dated November 19, 2018.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

