{"id":1715,"date":"2019-02-11T17:14:32","date_gmt":"2019-02-11T17:14:32","guid":{"rendered":"https:\/\/ubwp.buffalo.edu\/art320\/?page_id=1715"},"modified":"2022-09-18T15:24:28","modified_gmt":"2022-09-18T19:24:28","slug":"css-flexbox","status":"publish","type":"page","link":"https:\/\/ubwp.buffalo.edu\/art320\/exercises\/exercise-3-building-a-site-with-html-and-css\/css-flexbox\/","title":{"rendered":"CSS Flexbox"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Flex Basics<\/h2>\n\n\n\n<p>Flexbox (Flexible Box) is a direction-agnostic layout model which makes it more efficient to arrange and align items within a container. Unlike the direction-specific display of <code>block<\/code> (vertical) and <code>inline<\/code> (horizontal) objects, <code>flex<\/code> objects can be ordered in two directions, and can also expand to fill available space and shrink to prevent overflow. (Flexbox is a <a href=\"https:\/\/www.w3.org\/TR\/css-flexbox\/\">proposed recommendation to W3C<\/a>. It is not yet a final component of the CSS3 standard.)<\/p>\n\n\n\n<p>&gt; See&nbsp;<a href=\"https:\/\/css-tricks.com\/snippets\/css\/a-guide-to-flexbox\/\">A Complete Guide to Flexbox<\/a> on css-trick.com.<\/p>\n\n\n\n<p>Some flexbox properties can be added to parent items (<strong>flex containers<\/strong>) while others are to be used on children (<strong>flex items<\/strong>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Flex Container<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"310\" src=\"https:\/\/ubwp.buffalo.edu\/art320\/wp-content\/uploads\/sites\/103\/2019\/02\/flex-directions.png\" alt=\"\" class=\"wp-image-1722\" srcset=\"https:\/\/ubwp.buffalo.edu\/art320\/wp-content\/uploads\/sites\/103\/2019\/02\/flex-directions.png 660w, https:\/\/ubwp.buffalo.edu\/art320\/wp-content\/uploads\/sites\/103\/2019\/02\/flex-directions-300x141.png 300w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>main axis<\/strong> &#8211; The primary axis along which flex items are placed. Direction may not always be horizontal, depending on the <code>flex-direction<\/code>property.<\/li><li><strong>main-start | main-end<\/strong> &#8211; Flex items appear within the container starting from main-start and going to main-end.<\/li><li><strong>main size<\/strong> &#8211; A flex item&#8217;s width or height, whichever is in the main dimension.<\/li><li><strong>cross axis<\/strong> &#8211; The axis perpendicular to the main axis. Its direction depends on the main axis direction.<\/li><li><strong>cross-start | cross-end<\/strong> &#8211; Flex lines are filled with items and placed into the container starting on the cross-start side of the flex container and going toward the cross-end side.<\/li><li><strong>cross size<\/strong> &#8211; The width or height of a flex item, whichever is in the cross dimension, is the item&#8217;s cross size property.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Properties for Flex Containers<\/h3>\n\n\n\n<p><strong>display<\/strong> &#8211; defines a container as being flex, inline or block (default). All direct children will have flex context.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container <span class=\"token punctuation\">{\n<\/span><span class=\"token property\">    display<\/span><span class=\"token punctuation\">:<\/span> flex<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/* or inline-flex *\/\n<\/span>}<\/code><\/pre>\n\n\n\n<p><strong>flex-direction<\/strong> &#8211;&nbsp;establishes the main-axis, defining the direction flex items appear in the flex container,&nbsp;either in horizontal rows or vertical columns.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container {\n    flex-direction: row | row-reverse | column | column-reverse;\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><code>row<\/code> (default): left to right in <code>ltr<\/code>; right to left in <code>rtl<\/code><\/li><li><code>row-reverse<\/code>: right to left in <code>ltr<\/code>; left to right in <code>rtl<\/code><\/li><li><code>column<\/code>: same as <code>row<\/code> but top to bottom<\/li><li><code>column-reverse<\/code>: same as <code>row-reverse<\/code> but bottom to top<\/li><\/ul>\n\n\n\n<p><strong>flex-wrap<\/strong> &#8211; default behavior is for all items to try to fit in one line. This can be overridden by the flex-wrap property:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container {\n    <span class=\"token property\">flex-wrap<\/span><span class=\"token punctuation\">:<\/span> nowrap | wrap | wrap-reverse<span class=\"token punctuation\">;<\/span>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><code>nowrap<\/code>&nbsp;&#8211; (default behavior): all flex items will be on one line<\/li><li><code>wrap<\/code>&nbsp;&#8211; flex items will wrap onto multiple lines, from top to bottom.<\/li><li><code>wrap-reverse<\/code>&nbsp;&#8211; flex items will wrap onto multiple lines from bottom to top.<\/li><\/ul>\n\n\n\n<p>flex-flow<\/p>\n\n\n\n<p>justify-content<\/p>\n\n\n\n<p>align-items<\/p>\n\n\n\n<p>align-content<\/p>\n\n\n\n<p>Properties of Flex Items<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>order<\/li><li>flex-grow<\/li><li>flex-shrink<\/li><li>flex-basis<\/li><li>flex<\/li><li>align-self<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Flex Basics Flexbox (Flexible Box) is a direction-agnostic layout model which makes it more efficient to arrange and align items within a container. Unlike the direction-specific display of block (vertical) [&hellip;]<\/p>\n","protected":false},"author":295,"featured_media":0,"parent":358,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_EventAllDay":false,"_EventTimezone":"","_EventStartDate":"","_EventEndDate":"","_EventStartDateUTC":"","_EventEndDateUTC":"","_EventShowMap":false,"_EventShowMapLink":false,"_EventURL":"","_EventCost":"","_EventCostDescription":"","_EventCurrencySymbol":"","_EventCurrencyCode":"","_EventCurrencyPosition":"","_EventDateTimeSeparator":"","_EventTimeRangeSeparator":"","_EventOrganizerID":[],"_EventVenueID":[],"_OrganizerEmail":"","_OrganizerPhone":"","_OrganizerWebsite":"","_VenueAddress":"","_VenueCity":"","_VenueCountry":"","_VenueProvince":"","_VenueState":"","_VenueZip":"","_VenuePhone":"","_VenueURL":"","_VenueStateProvince":"","_VenueLat":"","_VenueLng":"","_VenueShowMap":false,"_VenueShowMapLink":false,"footnotes":""},"class_list":["post-1715","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/pages\/1715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/users\/295"}],"replies":[{"embeddable":true,"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/comments?post=1715"}],"version-history":[{"count":8,"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/pages\/1715\/revisions"}],"predecessor-version":[{"id":3107,"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/pages\/1715\/revisions\/3107"}],"up":[{"embeddable":true,"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/pages\/358"}],"wp:attachment":[{"href":"https:\/\/ubwp.buffalo.edu\/art320\/wp-json\/wp\/v2\/media?parent=1715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}