{"id":5080,"date":"2019-08-19T15:33:07","date_gmt":"2019-08-19T13:33:07","guid":{"rendered":"http:\/\/blog.via-internet.de\/?p=5080"},"modified":"2019-08-19T15:33:07","modified_gmt":"2019-08-19T13:33:07","slug":"bootstrap-coobook","status":"publish","type":"post","link":"https:\/\/via-internet.de\/blog\/2019\/08\/19\/bootstrap-coobook\/","title":{"rendered":"Bootstrap | Coobook"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Layout and Positioning<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">From <a href=\"https:\/\/medium.com\/wdstack\/bootstrap-4-vertical-center-1211448a2eff\">here<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now that Bootstrap 4 is&nbsp;<strong>flexbox by default,<\/strong>&nbsp;<strong>vertical alignment gets a little easier.&nbsp;<\/strong>In general, there are 3 different approaches to vertical alignment\u2026<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"https:\/\/getbootstrap.com\/docs\/4.3\/utilities\/flex\/#auto-margins\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Auto-margins<\/a><\/li><li><a href=\"https:\/\/getbootstrap.com\/docs\/4.3\/utilities\/flex\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Flexbox utilities<\/a><\/li><li><a href=\"https:\/\/getbootstrap.com\/docs\/4.3\/utilities\/display\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Display utilities<\/a>&nbsp;along with the&nbsp;<a href=\"https:\/\/getbootstrap.com\/docs\/4.3\/utilities\/vertical-align\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Vertical Align utilities<\/a>.<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">At first, the&nbsp;\u201c<a href=\"https:\/\/getbootstrap.com\/docs\/4.3\/utilities\/vertical-align\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Vertical Align\u201d utilities<\/a>&nbsp;would seem an obvious choice, but these&nbsp;<em>only<\/em>&nbsp;work with inline and table display elements. Consider the following vertical alignment options and scenarios.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In general, there are&nbsp;<em>2 types<\/em>&nbsp;of vertical alignment scenarios you\u2019ll encounter\u2026<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>vertical centering&nbsp;<strong>within a parent container.<\/strong><\/li><li>or, vertical centering&nbsp;<strong>relative to adjacent elements.<\/strong><\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">1. Vertical Center Using Auto Margins<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">One way to vertically center is to use&nbsp;<code>my-auto<\/code>. This will center the element within it\u2019s flexbox container (The Bootstrap 4&nbsp;<code>.row<\/code>&nbsp;is&nbsp;<code>display:flex<\/code>). For example,&nbsp;<code>h-100<\/code>&nbsp;makes the row full height, and&nbsp;<code>my-auto<\/code>&nbsp;will vertically center the&nbsp;<code>col-sm-12<\/code>&nbsp;column.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\"row h-100\">\n   &lt;div class=\"col-sm-12 my-auto\">\n     &lt;div class=\"card card-block w-25\">Card&lt;\/div>\n   &lt;\/div>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>my-auto<\/code>&nbsp;represents margins on the vertical y-axis, and is equivalent to:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">margin-top: auto;\nmargin-bottom: auto;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Demo<\/strong>&nbsp;\u2014&nbsp;<a href=\"https:\/\/www.codeply.com\/go\/uOJdVtWPfy\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Vertical Center Using Auto Margins<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Vertical Center with Flexbox<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Since the Bootstrap 4&nbsp;<code>.row<\/code>&nbsp;class is now&nbsp;<code>display:flex<\/code>&nbsp;you can simply use the new&nbsp;<code>align-self-center<\/code>&nbsp;flexbox utility on&nbsp;<em>any<\/em>&nbsp;column to vertically center it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\u201drow\u201d>\n   &lt;div class=\u201dcol-6 align-self-center\u201d>\n      &lt;div class=\u201dcard card-block\u201d>\n      Center\n      &lt;\/div>\n   &lt;\/div>\n   &lt;div class=\u201dcol-6\">\n      &lt;div class=\u201dcard card-inverse card-danger\u201d>\n      Taller\n      &lt;\/div>\n   &lt;\/div>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">or, use&nbsp;<code>align-items-center<\/code>&nbsp;on the entire&nbsp;<code>.row<\/code>&nbsp;to vertically center align&nbsp;<em>all<\/em><code>col-*<\/code>&nbsp;(columns) in the row\u2026<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\u201drow align-items-center\u201d>\n  &lt;div class=\u201dcol-6\u201d>\n     &lt;div class=\u201dcard card-block\u201d>\n     Center\n     &lt;\/div>\n  &lt;\/div>\n  &lt;div class=\u201dcol-6\u201d>\n     &lt;div class=\u201dcard card-inverse card-danger\u201d>\n     Taller\n     &lt;\/div>\n  &lt;\/div>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Demo&nbsp;<\/strong>\u2014&nbsp;<a href=\"https:\/\/www.codeply.com\/go\/87eA8e7ZeP\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Vertical Center Different Height Adjacent Columns<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Vertical Center Using Display Utils<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Bootstrap 4 has now has&nbsp;<a href=\"https:\/\/v4-alpha.getbootstrap.com\/utilities\/display-property\/\" target=\"_blank\" rel=\"noreferrer noopener\">display utils<\/a>&nbsp;that are used a wrapper for the CSS display propery such as<code>display:block<\/code>,&nbsp;<code>display:inline<\/code>,&nbsp;<code>display:table-cell, display:none<\/code>, etc.. These can be used with the<a href=\"https:\/\/v4-alpha.getbootstrap.com\/utilities\/vertical-align\/\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;vertical alignment utils<\/a>to align inline, inline-block or table cell elements.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\"row h-50\">\n  &lt;div class=\"col-sm-12 h-100 d-table\">\n    &lt;div class=\"card card-block d-table-cell align-middle\">\n    I am groot\n    &lt;\/div>\n  &lt;\/div>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Demo \u2014&nbsp;<a href=\"https:\/\/www.codeply.com\/go\/tvJsEohVK4\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">Vertical Center Using Display Utils<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"e18c\">More Vertical Center Examples<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/www.codeply.com\/go\/2n0BiBx3pz\" target=\"_blank\" rel=\"noreferrer noopener\">Bootstrap 4 Vertical Center in Equal Height Cards<\/a><br><a href=\"http:\/\/www.codeply.com\/go\/Kaby5SlKgM\/bootstrap-4-cards-alignment\" target=\"_blank\" rel=\"noreferrer noopener\">Bootstrap 4 Vertical Centering with Cards<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Layout and Positioning From here. Now that Bootstrap 4 is&nbsp;flexbox by default,&nbsp;vertical alignment gets a little easier.&nbsp;In general, there are 3 different approaches to vertical alignment\u2026 Auto-margins Flexbox utilities Display utilities&nbsp;along with the&nbsp;Vertical Align utilities. At first, the&nbsp;\u201cVertical Align\u201d utilities&nbsp;would seem an obvious choice, but these&nbsp;only&nbsp;work with inline and table display elements. Consider the following vertical alignment options and scenarios. In general, there are&nbsp;2 types&nbsp;of vertical alignment scenarios you\u2019ll encounter\u2026 vertical centering&nbsp;within a parent container. or, vertical centering&nbsp;relative to adjacent elements. 1. Vertical Center Using Auto Margins One way to vertically center is to use&nbsp;my-auto. This will center the element within [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5082,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10,16,17],"tags":[],"class_list":["post-5080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bootstrap","category-cookbook","category-css"],"jetpack_featured_media_url":"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2019\/08\/bootstrap-01.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/5080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/comments?post=5080"}],"version-history":[{"count":0,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/5080\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media\/5082"}],"wp:attachment":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media?parent=5080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/categories?post=5080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/tags?post=5080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}