
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
The min-width and max-width declaration for Flexbox doesn’t work on Safari? Why?
To make the Flexbox work on all the web browsers, use the min-width and max-width equivalents of flex. For example, for this −
min-width: 40%; max-width: 40%;
Use the CSS Shorthand Property. It states flex-grow | flex-shrink | flex-basis as shown in the below syntax −
flex: flex-grow flex-shrink flex-basis|auto;
For the above, we can set the Flex as −
flex: 0 0 40%;
Let us now see a Flexbox example that works on all the web browsers. We have two divs inside our parent div parentBox −
<div class='parentBox'> <div class='childBox'> <div class='babyChildBox'>Parent's Child</div> <div class='babyChildBox'>Parent's Child</div> </div> <! - - - !--> </div>
The style for the parent container. We have use the CSS Flex shorthand property −
.parentBox { display: flex; flex: 1 0 100%; background-color:yellow; border: 3px solid skyblue; }
For the Child i.e. childBox, we have again used the shorthand property to set the flexible length on flexible items −
.childBox { flex: 1 1 50% background-color: green; color: white; border: 1px solid blue; }
The nested child in the above .childBox is set with Flex. This and the above nests the flex containers −
.babyChildBox { flex: 1 1 50%; background-color: orange; }
Example
Here’s the complete example −
<!DOCTYPE html> <html> <head> <style> .parentBox { display: flex; flex: 1 0 100%; background-color:yellow; border: 3px solid skyblue; } .childBox { flex: 1 1 50% background-color: green; color: white; border: 1px solid blue; } .babyChildBox { flex: 1 1 50%; background-color: orange; } </style> </head> <body> <h1>Implementing Flex</h1> <div class='parentBox'> <div class='childBox'> <div class='babyChildBox'>Parent's Child</div> <div class='babyChildBox'>Parent's Child</div> </div> <div class='childBox'> <div class='babyChildBox'>Parent's Child</div> <div class='babyChildBox'>Parent's Child</div> </div> </div> </body> </html>
Output

- Related Articles
- Set min-width and max-width of an element using CSS
- Perform Animation on CSS min-width
- Python3 - Why loop doesn't work?
- Perform Animation on CSS max-width
- Setting a Fixed Width for Items in CSS Flexbox
- CSS min-width property
- How to set the min and max height or width of a Frame in Tkinter?
- CSS max-width property
- The min-width Property in CSS
- Use CSS max-width property for responsive image
- The max-width Property in CSS
- Use CSS max-width property responsive for video player
- CSS content: attr() on HTML5 progress doesn't work
- Why doesn't height: 100% work to expand divs to the screen height?
- Safari on iPad (iOS6) does not scale HTML5 video to fill 100% of page width

Advertisements