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 a block element?
<div> <img> <span>
<div>Web Programming and Development</div>
Which CSS code displays the text underlined?
font-style: italic; text-decoration: underline; font-weight: 500;
h2 {
  text-decoration: underline;
}
Click on the JavaScript function that can access other function after a specified time.
insertBefore() setTimeout() querySelector()
function someFunction() { alert("CoursesWeb.net"); }
setTimeout("someFunction()", 2000);
Click on the instruction that returns the number of items of a multidimensional array in PHP.
count($array) count($array, 1) strlen()
$food =["fruits" =>["banana", "apple"), "veggie" =>["collard", "pea"));
$nr_food = count($food, 1);
echo $nr_food;       // 6
CSS3 Flexbox Container

Last accessed pages

  1. Get Duration of Audio /Video file before Upload (15289)
  2. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (137642)
  3. EasyPhpThumbnail Class (1885)
  4. createElement and insertBefore (7332)
  5. SHA512 Encrypt hash in JavaScript (24769)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (331)
  2. Read Excel file data in PHP - PhpExcelReader (124)
  3. The Four Agreements (97)
  4. PHP Unzipper - Extract Zip, Rar Archives (94)
  5. The Mastery of Love (88)
Chat
Chat or leave a message for the other users
Full screenInchide