Simplify Your Workflow: Search MiniWebtool.
Add Extension
Related Tools
CSS Grid GeneratorLess to CSS CompilerSCSS to CSS CompilerTypeScript Playground
Home Page > Webmaster Tools > CSS Flexbox Playground

CSS Flexbox Playground

Interactive CSS Flexbox playground with live visual preview, per-item controls, real-world layout presets (Holy Grail, Card Grid, Navbar, Modal), and one-click CSS export. Learn flex-direction, justify-content, align-items, gap, and more by experimenting in real time.

CSS Flexbox Playground
โšก Quick Start Layouts (click to load)
โ–ฆ Live Preview
โ†’ main axis โ†“ cross axis 0 items tip: click any item to edit
โš™ Container (.flex-container)
flex-direction ?
flex-wrap ?
justify-content ?
align-items ?
align-content ?
gap 8px
8px
โœฆ Selected Item (.flex-item)
Click an item in the preview to edit its properties.
๐Ÿ“– Quick Cheatsheet โ€” common patterns
โ–ผ
I want toโ€ฆUse this
Center one item perfectlyjustify-content: center; align-items: center
Equal-width columnsflex: 1 on each item
Push one item to the rightmargin-left: auto on that item
Wrap cards on small screensflex-wrap: wrap + flex: 1 1 240px
Reverse order on mobileflex-direction: row-reverse in media query
Sticky footer at viewport bottombody: display: flex; flex-direction: column; min-height: 100vh
Even space between itemsjustify-content: space-between
Don't shrink an itemflex-shrink: 0 on it
Generated CSS
Generated HTML

Embed CSS Flexbox Playground Widget

About CSS Flexbox Playground

The CSS Flexbox Playground is an interactive learning environment and code generator for the modern CSS Flexible Box Layout module. Adjust container properties (flex-direction, justify-content, align-items, gap) and per-item properties (flex-grow, flex-shrink, flex-basis, align-self, order) and watch your layout update in real time. When you have something you like, copy ready-to-paste CSS and HTML straight into your project.

What is CSS Flexbox?

CSS Flexbox (Flexible Box Layout) is a one-dimensional layout model designed to distribute space along a single axis (a row or a column) and align items within a container. It replaces older techniques like floats and inline-block hacks for navbars, card rows, centered content, and any UI where elements need to flex naturally to their container. Unlike CSS Grid, which is two-dimensional, Flexbox excels at simpler arrangements where you control alignment in only one direction at a time.

How to Use This Playground

  1. Pick a preset (optional): Choose Holy Grail, Card Grid, Navbar, Hero, Modal, or Sticky Footer to load a real-world starting point. Each preset is a complete working layout you can study or modify.
  2. Adjust container properties: Use the segmented controls in the right panel to set flex-direction, flex-wrap, justify-content, align-items, align-content, and gap. The visual stage updates immediately.
  3. Edit individual items: Click any item in the preview to select it. Override its order, flex-grow, flex-shrink, flex-basis, and align-self independently of the rest. Items with overrides are marked with a small badge.
  4. Add or remove items: Use Add Item and Remove Selected to change the item count and see how the layout responds.
  5. Copy the code: The Generated Code section at the bottom always reflects your current layout. Copy CSS, HTML, or both with one click.

Container Properties Reference

The flex container is the parent element with display: flex. These properties control how all of its children behave together.

PropertyValuesEffect
flex-direction row ยท row-reverse ยท column ยท column-reverse Sets the main axis direction. row arranges items left-to-right (default); column stacks them vertically.
flex-wrap nowrap ยท wrap ยท wrap-reverse Controls whether items stay on one line or wrap onto multiple lines when space runs out.
justify-content flex-start ยท center ยท flex-end ยท space-between ยท space-around ยท space-evenly Aligns items along the main axis. Distributes free space to the sides or between items.
align-items stretch ยท flex-start ยท center ยท flex-end ยท baseline Aligns items along the cross axis (perpendicular to the main axis).
align-content stretch ยท flex-start ยท center ยท flex-end ยท space-between ยท space-around Aligns wrapped lines along the cross axis. Only takes effect when items wrap onto multiple lines.
gap length, e.g. 8px, 1rem Sets the gutter between flex items. Replaces the older margin-based spacing pattern.

Item Properties Reference

These properties go on individual flex items (children of a flex container) and override the container's defaults for just that item.

PropertyValuesEffect
order integer (default 0) Reorders items visually without changing the HTML. Lower numbers render first; negative values move items to the start.
flex-grow number (default 0) Defines how much of the container's free space this item should absorb relative to siblings. 1 on every item splits space equally.
flex-shrink number (default 1) Defines how much an item can shrink when there is not enough room. 0 means never shrink โ€” the item keeps its declared size.
flex-basis auto ยท length ยท percentage Sets the initial size of an item before free space is distributed. Effectively sets the item's "ideal" main-axis size.
align-self auto ยท same as align-items Overrides the container's align-items for a single item.

What is the Difference Between justify-content and align-items?

justify-content controls alignment along the main axis, while align-items controls alignment along the cross axis. The main axis is whichever direction flex-direction sets โ€” horizontal for row, vertical for column. When you change flex-direction from row to column, the two axes swap, so justify-content becomes vertical and align-items becomes horizontal. This swap is one of the most common sources of confusion when people learn Flexbox; the playground's axis indicators below the preview help make it visible.

How Do I Center an Element with Flexbox?

To center a single element both horizontally and vertically:

Three lines:
display: flex;
justify-content: center;  /* horizontal */
align-items: center;  /* vertical */

This is the modern replacement for older centering hacks involving margin: auto, transform: translate(-50%, -50%), or position: absolute. Try it in the playground by selecting the Modal Center preset.

Real-World Layout Presets Explained

Holy Grail Layout

The classic three-column page layout: left sidebar, main content, right sidebar โ€” with a header and footer. Historically very hard to build with floats; Flexbox makes it trivial. The middle column uses flex: 1 so it absorbs all the remaining horizontal space while the side columns stay at their declared widths.

Card Grid

A wrapping row of cards that flow onto new lines as the viewport narrows. Uses flex-wrap: wrap with each card given flex: 1 1 240px, meaning the card grows and shrinks but never gets narrower than 240px.

Navbar

A horizontal navigation bar with a logo on the left and links on the right. The trick is justify-content: space-between with the logo and link group as the two children, plus an internal flex container for the links themselves.

Hero Section

Vertical stack with content centered both horizontally and vertically โ€” perfect for landing-page hero areas. Uses flex-direction: column, justify-content: center, and align-items: center on a tall container.

Modal Center

A modal dialog perfectly centered within its overlay. The same three-line centering recipe shown above, applied to a full-screen overlay container.

Sticky Footer

A footer that sits at the bottom of the viewport when content is short, but pushes down when content is long. Achieved by giving the body display: flex; flex-direction: column; min-height: 100vh and the main content flex: 1.

What is the Difference Between flex-grow, flex-shrink, and flex-basis?

These three properties (combined into the shorthand flex) describe how an item handles space:

The shorthand flex: 1 expands to flex: 1 1 0% โ€” equal grow, equal shrink, zero basis โ€” meaning all items take an equal share of the container regardless of content. flex: auto expands to flex: 1 1 auto, which respects the content size as the basis.

When Should I Use Flexbox vs Grid?

Use Flexbox for one-dimensional layouts where items flow in a single direction โ€” a row of buttons, a navbar, a single column of cards. Flexbox is content-aware and great when you want items to size themselves.

Use CSS Grid for two-dimensional layouts where you need to control both rows and columns simultaneously โ€” full page layouts, image galleries, dashboards. Grid is layout-aware and lets you place items into named tracks.

The two are complementary, not competing. Many real designs combine them: a Grid page layout with Flexbox navbars and card rows inside.

Tips for Mastering Flexbox

Browser Support and Compatibility

CSS Flexbox is supported in every modern browser including Chrome, Firefox, Safari, Edge, and all major mobile browsers. The gap property in flex containers reached universal browser support in 2021. Older legacy browsers (IE10/11) require vendor prefixes and have several well-documented bugs; for those audiences, consider flexbugs.

Frequently Asked Questions

Why is my flex item overflowing the container?

Flex items have an implicit min-width: auto based on their content. Long words, code blocks, or pre-formatted text can force an item to be wider than the container. Fix it by setting min-width: 0 on the item (or min-height: 0 for column layouts).

What's the difference between space-between, space-around, and space-evenly?

space-between puts no space at the ends and equal space between items. space-around puts half a gap at each end and full gaps between items. space-evenly puts equal space at the ends and between items. Toggle them in the playground to feel the difference.

Can I animate flex properties?

Yes. flex-grow, flex-shrink, flex-basis, order, and gap can be transitioned. Animating flex-direction, justify-content, and align-items is not supported because they are discrete enumerated properties.

Does the playground work offline?

All Flexbox calculation happens in your browser using native CSS. Once the page is loaded, you can use the playground without an internet connection โ€” there are no API calls or server-side computation.

Is the generated code production-ready?

Yes. The exported CSS uses standard properties supported in every evergreen browser. The HTML uses semantic class names (flex-container, flex-item) you can rename to fit your project's conventions.

Additional Resources

Reference this content, page, or tool as:

"CSS Flexbox Playground" at https://MiniWebtool.com/css-flexbox-playground/ from MiniWebtool, https://MiniWebtool.com/

by miniwebtool team. Updated: Apr 25, 2026

Webmaster Tools:

Top & Updated:

Random PickerRandom Name PickerInstagram User ID LookupImage ResizerLine CounterRelative Standard Deviation CalculatorFPS ConverterSort NumbersFacebook User ID LookupRemove SpacesMAC Address GeneratorBatting Average CalculatorWord to Phone Number ConverterERA CalculatorMAC Address LookupSlope and Grade CalculatorMercury Retrograde CalendarFeet and Inches to Cm ConverterSum Calculator๐Ÿ“ท OCR / Image to Textโฌ› Aspect Ratio CalculatorPercent Off CalculatorSun, Moon & Rising Sign Calculator ๐ŸŒž๐ŸŒ™โœจRandom Quote GeneratorSHA256 Hash GeneratorRandom Credit Card GeneratorInvisible Text GeneratorMerge VideosAudio SplitterMaster Number CalculatorOPS CalculatorVertical Jump CalculatorRandom Truth or Dare GeneratorMP3 LooperBitwise CalculatorNumber of Digits CalculatorRandom IMEI Generator๐Ÿ–ฑ๏ธ Click CounterCompound Growth CalculatorLog Base 10 CalculatorBroken Link CheckerPhone Number ExtractorSquare Root (โˆš) CalculatorRandom Superpower GeneratorRandom Poker Hand GeneratorFile Size ConverterRoman Numerals ConverterCm to Feet and Inches ConverterSalary Conversion CalculatorOctal CalculatorRandom Activity GeneratorWeight Loss CalculatorRandom Fake Address GeneratorImage SplitterCaffeine Overdose CalculatorRandom Movie PickerBattery Life CalculatorYouTube Channel StatisticsSaturn Return CalculatorSun Position CalculatorRandom Birthday GeneratorWord Ladder GeneratorText FormatterNumber to Word ConverterRandom Writing Prompt GeneratorCompare Two StringsOn Base Percentage CalculatorRandom Meal GeneratorIP Subnet CalculatorLunar Calendar ConverterSlugging Percentage CalculatorStair CalculatorAdd Text to ImageName RandomizerSHA512 Hash GeneratorDecimal to BCD ConverterHalfway Date CalculatorAI Text HumanizerLong Division Calculator๐Ÿ“… Date CalculatorBinary to Gray Code ConverterVideo to Image ExtractorRandom Emoji GeneratorPercent Growth Rate CalculatorRandom Loadout GeneratorYouTube Tag ExtractorArc Length CalculatorList of Prime NumbersMartingale Strategy CalculatorRemove AccentBCD to Decimal ConverterVideo CompressorBcrypt Hash Generator / CheckerTime Duration CalculatorCone Flat Pattern (Template) GeneratorRatio to Percentage CalculatorWAR CalculatorAPI TesterFirst n Digits of PiRemove Lines Containing...Day of the Year Calculator - What Day of the Year Is It Today?Leap Years ListBingo Card GeneratorEmail ExtractorWord Scramble GeneratorProportion CalculatorBolt Torque CalculatorConnect the Dots GeneratorQuotient and Remainder CalculatorBreak Line by CharactersRandom User-Agent GeneratorCM to Inches ConverterFlip VideoAcreage CalculatorRandom Group GeneratorSmall Text Generator โฝแถœแต’แต–สธ โฟ แต–แตƒหขแต—แต‰โพRandom Tournament Bracket GeneratorDMS to Decimal Degrees ConverterNumber ExtractorImage CompressorOutlier CalculatorMD5 Hash GeneratorAstrological Element Balance CalculatorIP Address to Hex ConverterModulo CalculatorDecibel (dB) CalculatorAI Language DetectorGray Code to Binary ConverterWhat is my Zodiac Sign?MAC Address AnalyzerMolarity CalculatorHebrew Calendar ConverterSourdough CalculatorLove Compatibility CalculatorURL ExtractorTrigonometric Equation SolverPercent to PPM ConverterBinary to BCD ConverterEffect Size CalculatorSum of Positive Integers Calculator๐ŸŽฐ Gacha Pity CalculatorName Number CalculatorWHIP CalculatorDay of Year CalendarVideo SplitterVoronoi Diagram GeneratorWhat is my Lucky Number?Adjust Video SpeedLED Resistor Calculator๐Ÿ’ง Dew Point Calculator1099 Tax CalculatorAdd Prefix and Suffix to Text๐Ÿ” Plagiarism CheckerRandom Chord GeneratorBeer Chill Time CalculatorHeight Percentile CalculatorColor InverterPercentage Increase CalculatorSocial Media Username CheckerFirst n Digits of eReverse VideoRandomize NumbersPercentile CalculatorAmortization CalculatorRandom Number PickerSquare Numbers List๐Ÿ”Š Tone GeneratorBoiling Point CalculatorHTML Compressor๐ŸŽฒ Loot Drop Probability CalculatorAI ParaphraserDistance Between Two Points CalculatorRandom Name GeneratorDice RollerSort Text By LengthJob FinderWater Usage CalculatorRandom Time GeneratorText to Speech ReaderPVIFA CalculatorYouTube Thumbnail DownloaderCube Numbers ListMandelbrot Set ExplorerReverse TextSteel Weight CalculatorList RandomizerLottery Number GeneratorRatio CalculatorText RepeatPER CalculatorYouTube Earnings EstimatorCollage MakerMagic Square GeneratorRandom Math Problem GeneratorBlood Donation Time CalculatorEstimation CalculatorRandom Chess Opening GeneratorAI Punctuation AdderSort Lines AlphabeticallyHex to BCD ConverterBCD to Binary ConverterBCD to Hex ConverterMedian CalculatorStandard Error CalculatorAverage CalculatorHypotenuse CalculatorRemove Audio from VideoActual Cash Value CalculatorScientific Notation to Decimal ConverterAngel Number CalculatorLog Base 2 CalculatorRoot Mean Square CalculatorSHA3-256 Hash GeneratorAI Sentence ExpanderLbs to Kg ConverterHex to Decimal ConverterConvolution CalculatorRandom String GeneratorRemove Leading Trailing SpacesMarkup CalculatorPVIF CalculatorDecimal to Hex ConverterInstagram Font GeneratorSocial Media Image Size GuideTikTok Money CalculatorTwitter/X Character CounterTwitter/X Timestamp ConverterYouTube Watch Time CalculatorTwitch Earnings CalculatorYouTube Shorts Monetization CalculatorFacebook Ad Cost CalculatorSocial Media ROI CalculatorSocial Media Post Time OptimizerCTR CalculatorROAS CalculatorInfluencer ROI CalculatorForce CalculatorAcceleration CalculatorVelocity CalculatorMomentum CalculatorProjectile Motion CalculatorKinetic Energy CalculatorPotential Energy CalculatorWork and Power CalculatorDensity CalculatorPressure CalculatorIdeal Gas Law CalculatorFree Fall CalculatorTorque CalculatorHorsepower CalculatorDilution CalculatorChemical Equation BalancerStoichiometry CalculatorPercent Yield CalculatorEmpirical Formula CalculatorTitration CalculatorMole/Gram/Particle ConverterIrregular Polygon Area CalculatorFrustum CalculatorTorus Calculator3D Distance CalculatorGreat Circle Distance CalculatorCircumscribed Circle (Circumcircle) CalculatorInscribed Circle (Incircle) CalculatorAngle Bisector CalculatorTangent Line to Circle CalculatorHeron's Formula CalculatorCoordinate Geometry Distance CalculatorVolume of Revolution CalculatorSurface of Revolution CalculatorParametric Curve GrapherRiemann Sum CalculatorTrapezoidal Rule CalculatorSimpson's Rule CalculatorImproper Integral CalculatorL'Hรดpital's Rule CalculatorMaclaurin Series CalculatorPower Series CalculatorSeries Convergence Test CalculatorInfinite Series Sum CalculatorAverage Rate of Change CalculatorInstantaneous Rate of Change CalculatorRelated Rates SolverOptimization Calculator (Calculus)Gradient Calculator (Multivariable)Divergence CalculatorCurl CalculatorLine Integral CalculatorSurface Integral CalculatorJacobian Matrix CalculatorNewton's Method CalculatorRREF Calculator (Row Echelon Form)Matrix Inverse CalculatorMatrix Multiplication CalculatorDot Product CalculatorCross Product CalculatorVector Magnitude CalculatorUnit Vector CalculatorAngle Between Vectors CalculatorNull Space CalculatorColumn Space CalculatorCramer's Rule CalculatorMatrix Diagonalization CalculatorQR Decomposition CalculatorCholesky Decomposition CalculatorMatrix Power CalculatorCharacteristic Polynomial CalculatorBayes' Theorem CalculatorF-Test / F-Distribution CalculatorHypergeometric Distribution CalculatorNegative Binomial Distribution CalculatorGeometric Distribution CalculatorExponential Distribution CalculatorWeibull Distribution CalculatorBeta Distribution CalculatorSpearman Rank Correlation CalculatorFisher's Exact Test CalculatorContingency Table CalculatorOdds Ratio CalculatorBernoulli Equation CalculatorHeat Transfer CalculatorThermal Expansion CalculatorSpecific Heat Capacity CalculatorGear Ratio Calculator (Mechanical)Pulley System CalculatorHydraulic Cylinder Force CalculatorBelt Length CalculatorCloset Capsule CalculatorStorage Unit Size CalculatorMoving Box Quantity CalculatorGift Card Tip CalculatorGas vs Electric Cost ComparisonPrint Cost CalculatorHair Dye Mixing CalculatorLaundry Detergent Dosage CalculatorDishwasher Load OptimizerTile Grout CalculatorPaint Color Mixing CalculatorFlashcard Spaced Repetition SchedulerLearning Curve CalculatorCornell Notes GeneratorVocabulary Quiz GeneratorLanguage Learning Hours to Fluency CalculatorCollege Cost CalculatorScholarship ROI CalculatorAI Recipe Generator (From Ingredients)AI Gift Idea GeneratorAI Meal Plan GeneratorAI Workout Plan GeneratorAI Reading List GeneratorAI Travel Itinerary GeneratorAI Excuse Generator (Polite)AI Apology Letter WriterAI Unit Converter (Natural Language)AI Resume / CV AnalyzerAI Text Tone AnalyzerAI Data Visualizer (Paste CSV)AI Regex GeneratorAI SQL Query GeneratorPaycheck Calculator (Take-Home Pay)VA Loan CalculatorARM Mortgage CalculatorBiweekly Mortgage Payment CalculatorPMI CalculatorMortgage Points CalculatorBalloon Loan CalculatorInterest-Only Mortgage CalculatorConstruction Loan CalculatorLand Loan CalculatorBoat Loan CalculatorRV Loan CalculatorMotorcycle Loan CalculatorCar Affordability CalculatorOut-the-Door Price CalculatorRent Affordability CalculatorProrated Rent CalculatorRent Increase CalculatorMileage Reimbursement CalculatorPer Diem CalculatorInvoice GeneratorSalary Raise CalculatorSeverance Pay CalculatorHSA Calculator529 College Savings CalculatorI Bond CalculatorT-Bill CalculatorCD Ladder CalculatorCredit Utilization CalculatorLoan Comparison CalculatorGross-Up CalculatorSWP CalculatorRD CalculatorPPF CalculatorEPF CalculatorNPS CalculatorGratuity CalculatorHRA Exemption CalculatorUK Stamp Duty CalculatorZakat CalculatorTithe CalculatorBetting Odds ConverterPayPal Fee CalculatorStripe Fee CalculatorEtsy Fee CalculatoreBay Fee CalculatorAmazon FBA CalculatorShopify Profit CalculatorWholesale Price CalculatorCraft Pricing CalculatorDepreciation CalculatorEOQ CalculatorReorder Point CalculatorSafety Stock CalculatorFIFO / LIFO CalculatorContribution Margin CalculatorWorking Capital CalculatorCost Per Lead CalculatorEmail Marketing ROI CalculatorTip Pooling CalculatorWeek Number CalculatorAnniversary CalculatorHalf Birthday CalculatorSobriety CalculatorRetirement CountdownDate to Roman Numerals ConverterSunrise & Sunset CalculatorMoon Phase CalculatorNap CalculatorWorld ClockJulian Date ConverterISO 8601 Date FormatterChinese Gender PredictorImplantation CalculatorIVF Due Date CalculatorhCG Doubling Time CalculatorChild Height PredictorChild BMI Percentile CalculatorBaby Eye Color PredictorBaby Name GeneratorDiaper Size CalculatorBaby Milk Intake CalculatorCost of Raising a Child CalculatorEasy Grader (EZ Grader)CGPA to Percentage ConverterSAT Score CalculatorACT Score CalculatorAP Score CalculatorAttendance Percentage CalculatorPercentage to CGPA ConverterCitation Generator (APA/MLA/Chicago)AI Quiz GeneratorAI Lesson Plan GeneratorInteractive Periodic TableElectron Configuration Calculator