Css Course

- 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 is used to add lists into <ul> and <ol> elements?
<dt> <dd> <li>
<ul>
 <li>http://coursesweb.net/html/</li>
 <li>http://coursesweb.net/css/</li>
</ul>
Which value of the "display" property creates a block box for the content and ads a bullet marker?
block list-item inline-block
.some_class {
  display: list-item;
}
Which instruction converts a JavaScript object into a JSON string.
JSON.parse() JSON.stringify eval()
var obj = {
 "courses": ["php", "javascript", "ajax"]
};
var jsonstr = JSON.stringify(obj);
alert(jsonstr);    // {"courses":["php","javascript","ajax"]}
Indicate the PHP class used to work with HTML and XML content in PHP.
stdClass PDO DOMDocument
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue;    // CoursesWeb.net
CSS3 Flexbox Container

Last accessed pages

  1. Deco Tool (2719)
  2. jQuery Drag and Drop Rows between two similar Tables (12974)
  3. Creating Custom Colors (2363)
  4. Wake Up! (15294)
  5. GraidleChart Create Graphic Charts (2008)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (526)
  2. The Mastery of Love (65)
  3. CSS cursor property - Custom Cursors (63)
  4. Read Excel file data in PHP - PhpExcelReader (59)
  5. PHP-MySQL free course, online tutorials PHP MySQL code (44)