In this tutorial, we are going to learn how to use the various features available in Flexbox.

Similar documents
CSC Website Design, Spring CSS Flexible Box

This tutorial has been prepared for beginners to help them understand the basic functionalities of Gulp.

Scalable Vector Graphics commonly known as SVG is a XML based format to draw vector images. It is used to draw twodimentional vector images.

This is an introductory tutorial designed for beginners to help them understand the basics of Radius.

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Meteor

This is a brief tutorial that explains how to make use of Sqoop in Hadoop ecosystem.

This tutorial has been prepared for beginners to help them understand the simple but effective SEO characteristics.

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Drupal

Microsoft Excel is a spreadsheet tool capable of performing calculations, analyzing data and integrating information from different programs.

16A CSS LAYOUT WITH FLEXBOX

This tutorial will guide users on how to utilize TestLodge in reporting and maintaining the testing activities.

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer ASP.NET WP

Responsive Web Design (RWD)

So, this tutorial is divided into various chapters and describes the 5G technology, its applications, challenges, etc., in detail.

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. RichFaces

This is a small tutorial where we will cover all the basic steps needed to start with Balsamiq Mockups.

CSS Selectors. element selectors. .class selectors. #id selectors

This tutorial explains the key concepts of Web Dynpro with relevant screenshots for better understanding.

This tutorial will help both students as well as professionals who want to make their websites or personal blogs more attractive.

This tutorial also elaborates on other related methodologies like Agile, RAD and Prototyping.

This tutorial provides a basic understanding of how to generate professional reports using Pentaho Report Designer.

Introducing CSS Flexbox Layout

WebGL (Web Graphics Library) is the new standard for 3D graphics on the Web, designed for rendering 2D graphics and interactive 3D graphics.

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. WordPress

Graduating to Grid. An Event Apart Orlando

This tutorial is designed for software programmers who would like to learn the basics of ASP.NET Core from scratch.

SAP Lumira is known as a visual intelligence tool that is used to visualize data and create stories to provide graphical details of the data.

CSS Futures. Web Development

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Laravel

Notes - CSS - Flexbox

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

This tutorial is designed for those who would like to understand the basics of i-mode in simple and easy steps.

About the Tutorial. Audience. Prerequisites. Copyright and Disclaimer. PySpark

<link rel="stylesheet" href="

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. Graph Theory

Zen Garden. CSS Zen Garden

How to lay out a web page with CSS

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright DAX

subject to an additional IP rights grant found at polymer.github.io/patents.txt -->

Before you start with this tutorial, you need to know basic Java programming.

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Testing is the process of evaluating a system or its component(s) with the intent to find whether it satisfies the specified requirements or not.

Before proceeding with this tutorial, you should have a good understanding of the fundamental concepts of marketing.

You must have a basic understanding of GNU/Linux operating system and shell scripting.

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

This tutorial will show you, how to use RSpec to test your code when building applications with Ruby.

Parrot is a virtual machine designed to efficiently compile and execute bytecode for interpreted languages.

HTML and CSS COURSE SYLLABUS

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Joomla

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

This tutorial is prepared for beginners to help them understand the basic-to-advanced concepts related to GPRS.

This tutorial will help you understand JSON and its use within various programming languages such as PHP, PERL, Python, Ruby, Java, etc.

Memcached is an open source, high-performance, distributed memory object caching system.

Fixed-width. Liquid. Web Development 1 CS1115/CS5002. Types of layout. relative, fixed), CSS Flexbox layout or CSS Grid Layout

How to lay out a web page with CSS

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming

ICT IGCSE Practical Revision Presentation Web Authoring

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer DBMS

Before you start proceeding with this tutorial, we are assuming that you are already aware about the basics of Web development.

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Cascading Style Sheets CSCI 311

Tutorial 5 Working with Tables and Columns. HTML and CSS 6 TH EDITION

CSS. Shan-Hung Wu CS, NTHU

COMP519 Web Programming Lecture 8: Cascading Style Sheets: Part 4 Handouts

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

This tutorial will give you a quick start with Consul and make you comfortable with its various components.

This tutorial has been designed for beginners interested in learning the basic concepts of UDDI.

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. Jenkins

Getting Started with CSS Sculptor 3

Web Design and Implementation

ITEXT. [Document subtitle]

Web Design and Development Tutorial 03

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) More on Relative Linking. Learning Objectives (2 of 2)

Web Design, 5 th Edition

PUTTING FLEXBOX INTO PRACTICE. Blend Conference September Zoe Mickley

Building Page Layouts

CS193X: Web Programming Fundamentals

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. TurboGears

This tutorial will help you in understanding IPv4 and its associated terminologies along with appropriate references and examples.

the missing manual0 O'REILLY Third Edition David Sawyer McFarland Beijing Cambridge The book that should have been in the box Farnham

Leaflet.js is an open-source library using which we can deploy interactive, simple, lightweight and simple web maps.

Navigation. Websites need a formalized system of links to allow users to navigate the site

Styles, Style Sheets, the Box Model and Liquid Layout

Block & Inline Elements

Comm 244 Week 3. Navigation. Navigation. Websites need a formalized system of links to allow users to navigate the site

Adobe Flex Tutorial i

HIERARCHICAL ORGANIZATION

Getting Started with Eric Meyer's CSS Sculptor 1.0

Front-End UI: Bootstrap

Page Layout Using Tables

You should have a basic understanding of Relational concepts and basic SQL. It will be good if you have worked with any other RDBMS product.

HTML Organizing Page Content

Micronet International College

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

The Importance of the CSS Box Model

IDM 222. Web Design II. IDM 222: Web Authoring II 1

Transcription:

About the Tutorial Flexbox (flexible box) is a layout mode of CSS3. Using this mode, you can easily create layouts for complex applications and web pages. Flexbox layout gives complete control over the direction, alignment, order, size of the boxes. In this tutorial, we are going to learn how to use the various features available in Flexbox. Audience This tutorial has been prepared for beginners to make them understand the basics of Flexbox library. It will help the readers in aligning the contents of a webpage easily. Prerequisites For this tutorial, it is assumed that the readers have a prior knowledge of CSS and HTML Copyright & Disclaimer Copyright 2017 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at contact@tutorialspoint.com i

Table of Contents About the Tutorial... i Audience... i Prerequisites... i Copyright & Disclaimer... i Table of Contents... ii 1. FLEXBOX OVERVIEW...1 What is Flexbox?... 1 Features of Flexbox... 1 Supporting browsers... 2 2. FLEXBOX FLEX CONTAINERS...3 Flex... 3 Inline flex... 5 3. FLEXBOX FLEX-DIRECTION...7 row... 7 row-reverse... 9 column... 10 column-reverse... 12 4. FLEXBOX FLEX-WRAP...15 wrap... 16 wrap-reverse... 17 wrap (column)... 19 wrap-reverse (column)... 21 ii

5. FLEXBOX JUSTIFYING CONTENTS...23 flex-start... 24 flex-end... 25 center... 26 space-between... 28 space-around... 29 space-evenly... 31 6. FLEXBOX ALIGN ITEMS...33 flex-start... 33 flex-end... 35 center... 36 stretch... 38 baseline... 40 7. FLEXBOX ALIGN CONTENT...42 center... 42 flex-start... 44 flex-end... 46 stretch... 48 space-around... 50 space-between... 52 8. FLEXBOX FLEX-ORDER...55 9. FLEXBOX FLEXIBILITY...58 flex-basis... 58 flex-grow... 59 flex-shrink... 60 iii

flex... 61 10. FLEXBOX ALIGN SELF...62 flex-start... 62 flex-end... 64 center... 65 stretch... 67 iv

1. FLEXBOX OVERVIEW Flexbox Cascading Style Sheets (CSS) is a simple design language intended to simplify the process of making web pages presentable. CSS handles the look and feel part of a web page. Using CSS, you can control the color of the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background images or colors are used, layout designs, variations in display for different devices and screen sizes as well as a variety of other effects. To determine the position and dimensions of the boxes, in CSS, you can use one of the layout modes available The block layout: This mode is used in laying out documents. The inline layout: This mode is used in laying out text. The table layout: This mode is used in laying out tables. The positioned layout: This mode is used in positioning the elements. All these modes are used to align specific elements like documents, text, tables, etc., however, none of these provides a complete solution to lay out complex websites. Initially this is used to be done using a combination of floated elements, positioned elements, and table layout (often). But floats only allow to horizontally position the boxes. What is Flexbox? In addition to the above-mentioned modes, CSS3 provides another layout mode Flexible Box, commonly called as Flexbox. Using this mode, you can easily create layouts for complex applications and web pages. Unlike floats, Flexbox layout gives complete control over the direction, alignment, order, size of the boxes. Features of Flexbox Following are the notable features of Flexbox layout: Direction: You can arrange the items on a web page in any direction such as left to right, right to left, top to bottom, and bottom to top. Order: Using Flexbox, you can rearrange the order of the contents of a web page. Wrap: In case of inconsistent space for the contents of a web page (in single line), you can wrap them to multiple lines (both horizontally) and vertically. Alignment: Using Flexbox, you can align the contents of the webpage with respect to their container. 5

Resize: Using Flexbox, you can increase or decrease the size of the items in the page to fit in available space. Supporting browsers Following are the browsers that support Flexbox. Chrome 29+ Firefox 28+ Internet Explorer 11+ Opera 17+ Safari 6.1+ Android 4.4+ ios 7.1+ 6

2. FLEXBOX FLEX CONTAINERS Flexbox To use Flexbox in your application, you need to create/define a flex container using the display property. Usage: display: flex inline-flex This property accepts two values flex: Generates a block level flex container. inline-flex: Generates an inline flex container box. Now, we will see how to use the display property with examples. Flex On passing this value to the display property, a block level flex container will be created. It occupies the full width of the parent container (browser). The following example demonstrates how to create a block level flex container. Here, we are creating six boxes with different colors and we have used the flex container to hold them. <!doctype html> <html lang="en"> <style>.box1{background:green;}.box2{background:blue;}.box3{background:red;}.box4{background:magenta;}.box5{background:yellow;}.box6{background:pink;}.container{ } display:flex;.box{ font-size:35px; 7

} padding:15px; </style> <body> <div class="container"> <div class="box box1">one</div> <div class="box box2">two</div> <div class="box box3">three</div> <div class="box box4">four</div> <div class="box box5">five</div> <div class="box box6">six</div> </div> </body> <html> It will produce the following result Since we have given the value flex to the display property, the container uses the width of the container (browser). You can observe this by adding a border to the container as shown below..container{ display:inline-flex; border:3px solid black; } 8

It will produce the following result Inline flex On passing this value to the display property, an inline level flex container will be created. It just takes the place required for the content. The following example demonstrates how to create an inline flex container. Here, we are creating six boxes with different colors and we have used the inline-flex container to hold them. <!doctype html> <html lang="en"> <style>.box1{background:green;}.box2{background:blue;}.box3{background:red;}.box4{background:magenta;}.box5{background:yellow;}.box6{background:pink;}.container{ display:inline-flex; border:3px solid black; 9

}.box{ font-size:35px; padding:15px; } </style> <body> <div class="container"> <div class="box box1">one</div> <div class="box box2">two</div> <div class="box box3">three</div> <div class="box box4">four</div> <div class="box box5">five</div> <div class="box box6">six</div> </div> </body> <html> It will produce the following result Since we have used an inline flex container, it just took the space that is required to wrap its elements. 10

End of ebook preview If you liked what you saw Buy it from our store @ https://store.tutorialspoint.com 11