- flex-direction
- flex-wrap
- flex-flow
- justify-content
- align-items
- align-content
- Flexbox playground

Flexbox (or Flexible boxe) is a new layout mode in CSS3, intended to accommodate different screen sizes and different display devices.
The flexible box model does not use floats, nor do the flex container's margins collapse with the margins of its contents.
Flexbox gives us complete control over the alignment, direction, order, and size of our boxes.

Flexbox layouts
- This tutorial presents examples and css3 properties for the Flex container.

Creating a flexbox container

Flexbox consists of flex containers and flex items.
To define a flex container, set the display property of an element to flex (rendered as a block) or inline-flex (rendered as inline).
Each child of a flex container becomes a flex item. Text directly contained in a flex container is wrapped in an anonymous flex item.
<style>
.container {
display: ; /* or: inline-flex */
margin:2px;
padding:3px;
}
.container .item {
background:#ccccfe;
margin:2px;
}
</style>

- Content Before..
<div class='container'>
 Parent content.
 <div class='item'>Child 1</div>
 <div class='item'>Child_2</div>
 <div class='item'>Child-3</div>
</div>
- Content After..
Result:
- Content Before..
Parent content.
Flex item #1
Child 2
Flexbox child 3
- Content After..

Flexbox container properties

flex-direction

The flex-direction property specifies the direction of the flexible items inside the flex container. They can be laid out in two main directions, like rows horizontally or like columns vertically.
- flex-direction values: Flexbox direction
Example with inline-flex and column:
.container {
 display: inline-flex;
 flex-direction: column;
}

flex-wrap

By default, the flex container sets its items in one single line.
The flex-wrap property controls if the flex container lay out its items in single or multiple lines, and the direction the new lines are stacked in.
- flex-wrap values: Flexbox flex-wrap
.container {
 display: flex;
 flex-wrap: wrap;
}

flex-flow

flex-wrap is a shorthand for setting the flex-direction and flex-wrap properties, which together define the flex container's main and cross axes. Default is row nowrap
- flex-flow syntax:
flex-flow: flex-direction flex-wrap;
.container {
 display: flex;
 flex-flow: row wrap;
}

justify-content

justify-content horizontally aligns the flexible container's items when the items do not use all available space on the main-axis. It helps distribute left free space when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size.
- justify-content values: Flexbox justify-content
.container {
 display: flex;
 justify-content: space-around;
}

align-items

align-items vertically aligns the flexible container's items when the items do not use all available space on the cross-axis. It is similar to justify-content but in the perpendicular direction.
- align-items values: Flexbox align-items
.container {
 display: flex;
 align-items: center;
}

align-content

align-content aligns a flex container's lines within when there is extra space in the vertical-axis, similar to how justify-content aligns individual items within the horizontal-axis.
This property has no effect when there is only one line of flex items.
- align-content values: Flexbox align-content
.container {
 display: flex;
 align-content: space-around;
}

Flexbox playground

Here's a flex playground where you can combine and play with several css flex properties.
.container {
display: ;
flex-direction: ;
flex-wrap: ;
justify-content: ;
align-items: ;
align-content: ;
margin:2px;
padding:3px;
height: ;
width: ;
}
.container .item {
background:#ccccfe;
height:50px;
margin:2px;
}
Demo:
- Content Before..
Parent content.
Flex item #1
Child 2
Flexbox child 3
- Content After..

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag renders as emphasized text, displaying the text oblique?
<strong> <pre> <em>
<p>Web development courses: <em>CoursesWeb.net</em></p>
Which CSS property defines the space between the element border and its content?
margin padding position
h3 {
  padding: 2px 0.2em;
}
Click on the method which returns the first element that matches a specified group of selectors.
getElementsByName() querySelector() querySelectorAll()
// gets first Div with class="cls", and shows its content
var elm = document.querySelector("div.cls");
alert(elm.innerHTML);
Indicate the PHP variable that contains data from a form sent with method="post".
$_SESSION $_GET $_POST
if(isset($_POST["field"])) {
  echo $_POST["field"];
}
CSS3 Flexbox Container

Last accessed pages

  1. String Object (415)
  2. Detect when page visibility state is changed (64)
  3. Get Attribute (ID, Class, Name, Title, Src) with jQuery (52162)
  4. HTML Course - Free Lessons (10923)
  5. Register and show online users and visitors (22293)

Popular pages this month

  1. Read Excel file data in PHP - PhpExcelReader (369)
  2. Register and show online users and visitors (344)
  3. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (311)
  4. Insert, Select and Update NULL value in MySQL (247)
  5. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (244)