CSS FlexBox Model: What sets apart 'flex' from 'box-flex'?

When working with the CSS flex box model, there is a diverse range of properties available.

What sets apart the following properties from each other?

-webkit-flex: 1;
-moz-flex: 1;
-ms-box-flex: 1;
box-flex: 1;

compared to

-webkit-flex: 1;
-moz-box-flex: 1;
flex: 1;

Is there a way to combine both the old and new syntax together effectively?

Answer №1

box-flex was previously used in the old flexbox specification where only one "flexibility" value needed to be specified instead of separate values for "growing", "shrinking", and "basis". Today, you can use more detailed specifications.

      NEW             OLD
flex:1 1 auto; == box-flex:1;
flex:1 0 auto; == no equivalent

The multiple specifications in flexbox can be confusing due to different functionalities in each spec. It is advisable to establish fallbacks later on, especially when using -grow, -shrink, -basis, and -wrap, which may require a completely different layout as a backup plan.

If you are new to flexbox, it's recommended to start with the modern [almost] standard syntax found at

Afterwards, add support for older browsers selectively - focusing on MSIE10 and old -webkit- syntaxes (for targeting ancient Android devices). The -moz- syntax is generally deemed unnecessary in this context.


To cater to android 2 users, utilizing the old syntax is essential. Avoid relying on flex-wrap since it lacks support in outdated browsers (even some newer versions like Firefox), opt for flex:1 1 auto; as other values are not viable with the old syntax. Features like space-between and other modern flexbox enhancements may not function well in the former flexbox specs (excluding the 2011 version); hence, it's best to avoid them if possible. Essentially, stick to these safe properties/values:

flex: set to 1 1 auto

flex-direction: (box-orient)

justify-content: flex-start | flex-end | center
(box-pack)

align-items: flex-start | flex-end | center | baseline | stretch
(box-align)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When the LI element is clicked, it triggers the display of another LI element without affecting the rest of the

New to the web development scene and trying to figure out how to create a collapsible text feature using HTML, JavaScript, and JQuery. I've got the styling down but struggling with the scripting part. Here's an example of what I'm trying to ...

Connecting external websites in XAMPP: A beginner's guide

While using Xampp, I encountered an issue when attempting to access any online website with the following code: <a href="www.xyz.com">Click</a> Instead of directing me to www.xyz.com, it displays this in the URL field: localhost/www.xyz.com ...

What is the best way to resize several divs while ensuring they remain within a specific container?

In the process of creating a grid UI, I want users to be able to click on cells and scale them. Intended Outcome: Cells should be prevented from scaling out of the container and being cropped. Cells can overlap with one another when scaled. Only one cel ...

Inspect the variable in JavaScript and then increment it by one every second

I am facing an issue where I need to check a variable. If it's 0, then I need to increment it after 1.5 seconds. If it's 10, then I need to increment it after 0.4 seconds. It's quite complex and the current code implementation is not working ...

`At a loss: jQuery failing to retrieve JSON data`

I'm having trouble with a basic script that is supposed to fetch data from a JSON feed and display it in an alert. Despite having loaded jQuery correctly and checked for common issues, the code doesn't seem to be working. I am using jQuery and ca ...

Tips for arranging cards in a stacked position: To create a visually

I'm currently developing a project using react typescript, and I need to showcase various projects in the form of cards. However, I would like these cards to be displayed in a stacked layout like this Here is the component for displaying the projects ...

Creating an Angular form that adapts to changing input values

I'm encountering a problem with angular not recognizing the dynamic values from my inputs. My objective is to have angular populate hidden form fields with lat/lon when a user clicks on the map. The user then submits the form, but the data ends up mi ...

Background Image Troubling CSS Issue

I am having an issue with adding a background image to my site header. The main content should cover part of the image, but even after setting the z-index, it's not working as expected. You can view the website here Any ideas why this might be happe ...

Prevent body from scrolling when mouse is over a div, while keeping the position unchanged

Although I've come across a few discussions about this topic before (including one of my own), I'm still searching for an improvement on the only solution that has actually worked for me. My goal is to enable mouse wheel scrolling for a height-l ...

The issue at hand is that one of the JavaScript buttons is functioning properly, while the other is not playing the video as intended. What steps can

I've been working on a script for my school project website that should make buttons play videos, but I'm running into an issue where it only works for the first button (btn). Programming isn't my strong suit, and I put this together based o ...

Chrome's struggle with displaying multiple backgrounds on retina screens due to CSS complications

My goal is to create top and bottom shadows for a parent container when scrolling through the content. This effect works perfectly everywhere except on Chrome browser with retina screens, where it behaves strangely. The background becomes stuck at the top, ...

The clipPath feature in webkit fails to display correctly

After reading this insightful article, I decided to experiment with applying a gradient clip-path to a simple shape (an O letter converted to curves). To my frustration, the technique worked perfectly in Firefox but failed to render anything in webkit bro ...

What is the best way to decrease the width of a textfield in jQuery mobile?

Is there a way to decrease the width of a textfield in jQuery mobile? Check out this Fiddle for reference The CSS provided below does not seem to be working properly: #co label{ color: red !important; width: 100px !important; margin :30px; ...

A fixed header list using CSS with a single scroll bar

I am looking to create a scrollable list with a fixed header, where the scroll bar extends the full height of the parent but only scrolls through the nav items (keeping the logo in place). My current setup involves: <div className="home-page-nav"> ...

Disabling the ESC key from clearing input fields in Bootstrap-5: A step-by-step guide

I have come across this code snippet for a search field: <form class="container" role="search"> <div class="row"> <div class="col-12"> <input name="searchItem" #search ...

Is it possible to loop through a subset of a collection using *ngFor?

Is it possible to iterate through a specific range of elements in a collection using *ngFor? For instance, I have a group of checkboxes with their form control name and label specified as follows: [{id: 'c1', label: 'C1'}, ...] Assum ...

Tips for ensuring that content doesn't shift down when clicking a drop-down menu

I currently have three dropdowns that function as an accordion. When I click on one dropdown, the rest of the content below shifts down, which is not the behavior I want. Is there a way to prevent the content below each dropdown from moving when a dropdow ...

The scaling feature in CSS does not function properly in Internet Explorer 8

I've tried multiple approaches to transform the IE Matrix, but I'm facing an issue with the transform scale CSS not functioning in IE8. Code: .fture_box ul li.fture_img img{ width: 451px; height: 284px; display: block; margin: 0 0px 0 11px; pad ...

What is the best way to retrieve both the checked and unchecked values from a collection of checkboxes?

Check Out This live Example: I am in the process of creating a list of checkboxes with various data objects: data = [ { Key: "class_id", displayName: "Section ID", enabled: true }, { Key: "room_l4", displayName: "Location", enabled: false }, { Key: "se ...

Ways to receive notification during the user's selection of an option by hovering over it

Is there a way to receive an event when a user hovers over a select option? I thought that using the onMouseOver or onDragOver props on the option component would work, but it seems like they only trigger for the parent select component. Below is a simpli ...