CSS Layout: Flexbox.

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors.
Advertisements

Use Tables for Layout Control Day 7. You will learn to: Understand Tables Create a Simple Table Modify Your Tables Appearance Create Page Layouts with.
Chapter 3 – Web Design Tables & Page Layout
J ENWARE Chapters 14 & 15 Learning Web Design, Fourth Edition by Jennifer Niederst Robbins Copyright © 2012.
CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
Floating Elements CS380.
Web Design HTML Basic Robertus Setiawan Aji Nugroho References: w3schools.com.
TUTORIAL 4: CREATING PAGE LAYOUT WITH CSS Session 4.3.
Chapter 5 Working with Tables. Agenda Add a Table Assign a Table Border Adjust Cell Padding and Spacing Adjust Cell Width and Height Add Column Labels.
IMAGES Controlling size of images in CSS Aligning images in CSS Adding background images.
Tutorial 6 Creating Tables and CSS Layouts. Objectives Session 6.1 – Create a data table to display and organize data – Modify table properties and layout.
Principles of Web Design 6 th Edition Chapter 7 – Page Layouts.
ITP 104.  While you can do things like this:  Better to use styles instead:
CSS = Cascading Style Sheet CSS consists of rules to display, style and decorate HTML elements Why CSS ? – Separate decoration from HTML markup (Ex :,,…)
COMP 135 Web Site Design Intermediate
CSS WORKSHOP Design Principles for Web Standards.
CIS234A Lecture 8 Instructor Greg D’Andrea. Review Text Table contains only text, evenly spaced on the Web page in rows and columns uses only standard.
CSS Class 2 -Add margins to elements on a page. -Set width and height of elements. - CSS shorthand properties for box model. -Style links. -Style tables.
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  float & clear  display & visibility.
CSS Layout Arrangement and Positioning of the HTML Elements SoftUni Team Technical Trainers Software University
CONTROLLING Page layout
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
Nesting and Floating. Nesting and Floating Elements To make our page content appear the way we want, and to make the best use of screen space, we can.
>> CSS Layouts. Recall Properties of Box – Border (style, width, color) – Padding – Margin – Display – Background – Dimension Welcome Padding Area Border.
Agenda The User Interface The CSS Box Model The Flexbox Box Model Grid Layouts.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
Cascading Style Sheets for layout
CSS.
Laying out Elements with CSS
Cascading Style Sheets Layout
CSS Box Model.
Cascading Style Sheets Boxes
Animation and Flexboxes
Implementing Responsive Design
CSS Layouts: Grouping Elements
Microsoft Office 2007-Illustrated
Positioning Objects with CSS and Tables
Floating & Positioning
Web Development & Design Foundations with HTML5 8th Edition
Breaking the mold with CSS
Display Property.
Cascading Style Sheets for layout
Flexbox CSCI 1720 East Tennessee State University Department of Computing CSCI 1720 Intermediate Web Design.
CS3220 Web and Internet Programming Page Layout with CSS
CS3220 Web and Internet Programming Page Layout with CSS
>> CSS Layouts.
Objectives Create a media query Work with the browser viewport
CSS part 2 Outro.
The Internet 10/25/11 XHTML Tables
Objectives Create a reset style sheet Explore page layout designs
Fixed Positioning.
CSS Borders and Margins.
MORE Cascading Style Sheets (The Positioning Model)
Tutorial 3 – Creating a Multiple-Page Report
Responsive Framework.
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Responsive Web Design (RWD)
Floating and Positioning
CS3220 Web and Internet Programming Page Layout with CSS
Laying out Elements with CSS
Lesson 5: HTML Tables.
Bootstrap 4 December 17, 2018.
CSS Box Model.
CSS Box Model.
Web Client Side Technologies Raneem Qaddoura
Positioning Objects with CSS and Tables
CSc 337 Lecture 5: Grid layout.
Cascading Style Sheets CSS LAYOUT WITH GRID
CGS 3066: Web Programming and Design Fall 2019 CSS Part 2
Presentation transcript:

CSS Layout: Flexbox

CSS Layout Techniques Flexible Box Layout Module - Flexbox CSS Layout Module – offers greater control over arranging components of web page items along one axis (Ex: menu bars, product listings, galleries) Advantages of Flexbox Ability to “flex” – stretch or shrink inside their containers Ability to make all neighboring items the same height Easy horizontal and vertical centering Ability to change the display order of items independent of the html source *Browser Support – older browsers require prefixes/additional code for flexbox to work properly

CSS Layout - Flexbox Flexbox Container you create a flex container by setting the element’s display property to flex Figure 16-2. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc. .flex-container { display: flex; } .flex-container { display: inline-flex; } /* or */ Display: flex creates a block-level flex container Display: inline-flex creates an inline-level flex container

CSS Layout - Flexbox Flex container - Flex items applying the flex display mode turns the child elements of the flex container into flex items Figure 16-2. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc. Note: You can turn any flex item into a flex container by setting its display to flex (resulting in nested flexbox)

CSS Layout - Flexbox Flex container - Properties flex container properties allow you to control how items appear within the container flex-direction row | column | row-reverse | column-reverse Figure 16-3. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox flex items flex items line up along one axis main axis -or- cross axis The main axis is the flow direction you’ve specified for the flex container. The cross axis is perpendicular to the main axis Note: axis direction is specific to the direction of the writing system in use. For example: In horizontally oriented languages – “row” would align items horizontally Vertically oriented languages – “row” would align items vertically Figure 16-4. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox flex-wrap nowrap | wrap | wrap-reverse THE MARKUP Figure 16-5. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc. THE MARKUP <div id=“container”> <div class=“box box1”> 1</div> <!– more boxes here  <div class=“box box10”> 10 </div> </div> THE STYLES #container { display: flex; flex-direction: row; flex-wrap: wrap; } .box { width: 25%; }

CSS Layout - Flexbox flex-wrap nowrap | wrap | wrap-reverse Figure 16-5. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox flex-wrap nowrap | wrap | wrap-reverse THE MARKUP <div id=“container”> <div class=“box box1”> 1</div> <!– more boxes here  <div class=“box box10”> 10 </div> </div> THE STYLES #container { display: flex; height: 350px; flex-direction: column; flex-wrap: wrap; } .box { width: 25%; } Figure 16-6. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox flex-flow (shorthand) flex-direction flex-wrap Using flex-direction & flex-wrap #container { display: flex; height: 350px; flex-direction: column; flex-wrap: wrap; } Using flex-flow #container { display: flex; height: 350px; flex-flow: column wrap; }

CSS Layout - Flexbox Flexbox Alignment Properties justify-content flex-start | flex-end | center | space-between | space-around Flex items are, by default, as wide as they need to be to contain the element’s content. The justify-content property defines how extra space is distributed around or between items Figure 16-8. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox justify-content flex-start | flex-end | center | space-between | space-around Flex items are, by default, as wide as they need to be to contain the element’s content. The justify-content property defines how extra space is distributed around or between items Figure 16-8. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flexbox Alignment Properties align-items flex-start | flex-end | center | baseline | stretch The align-items property allows you to arrange items on the cross axis (up and down when the direction is row, left and right if the direction is column) *Note: you must specify a container height Figure 16-10. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flexbox Alignment Properties align-content flex-start | flex-end | center | space-around | space-between | stretch Figure 16-10. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc. The align-content property applies only when there are multiple wrapped flex lines

CSS Layout - Flexbox Flex item - Properties flex item properties determines how space is distributed within items flex None | ‘flex-grow flex-shrink flex-basis’ Flex: flex-grow flex-shrink flex-basis Example li { flex: 1 0 200px } Example This list item starts at 200px wide is allowed to grow to fill extra space is NOT allowed to shrink below 200px Values of 1 and 0 work as on/off switch 1 “turns on” or allows an item to grow or shrink 0 “turns off” prevents item from growing or shrinking

CSS Layout - Flexbox Flex item - Properties flex-grow Value: number Default: 0 THE MARKUP <div id=“container”> <div class=“box box1”> 1</div> <div class=“box box2”> 2</div> <div class=“box box3”> 3</div> <div class=“box box4”> 4</div> <div class=“box box5”> 5 </div> </div> THE STYLES .box { … flex: 1 1 auto; } Figure 16-18. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flex item - Properties flex-grow Value: number Default: 0 Assigning a higher integer to an item – applies more space within that item. A flex-grow value of “3” means the item receives three times the amount of space than the remaining items set to flex-grow: 1 Figure 16-19. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flex item - Properties flex-shrink Value: number Default: 1 When flex-shrink is 0, items are not permitted to shrink and may hang out of their containing element Flex items stop shrinking when they reach their minimum size (defined by min-width/min-height). Figure 16-20. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flex item - Properties flex-basis Value: length | percentage | content | auto Flex-basis defines the starting size of an item before any wrapping, growing or shrinking occurs. It may be used instead of the width property (or height for columns) for flex items. By default, flex-basis is set to auto (width/height value of item size) If item’s size is not defined or set to auto – flex-basis uses the content width. Figure 16-20. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flex item - Properties order Value: integer The order property give the ability to display items in an order that is different from the order in the HTML source code. If items have the same order value = laid out in order they appear in code If items have different order values = arranged from the lowest order value to highest. Figure 16-22. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flex item - Properties order Value: integer Figure 16-23&24. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

CSS Layout - Flexbox Flex item - Properties order Value: integer Figure 16-25. Niederst, J. (2018). Learning Web Design. O'Reilly Media, Inc.

Let’s see how this works…