{"id":1029,"date":"2018-02-23T17:20:59","date_gmt":"2018-02-23T16:20:59","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=1029"},"modified":"2018-02-23T17:20:59","modified_gmt":"2018-02-23T16:20:59","slug":"css-centering-in-the-unknown","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/css-centering-in-the-unknown\/","title":{"rendered":"CSS Centering in the unknown"},"content":{"rendered":"<p>Source: <a href=\"https:\/\/css-tricks.com\/centering-in-the-unknown\/\">https:\/\/css-tricks.com\/centering-in-the-unknown\/<\/a><\/p>\n<pre class=\"lang:css decode:true\">\/* This parent can be any width and height *\/\r\n.block {\r\n  text-align: center;\r\n\r\n  \/* May want to do this if there is risk the container may be narrower than the element inside *\/\r\n  white-space: nowrap;\r\n}\r\n \r\n\/* The ghost, nudged to maintain perfect centering *\/\r\n.block:before {\r\n  content: '';\r\n  display: inline-block;\r\n  height: 100%;\r\n  vertical-align: middle;\r\n  margin-right: -0.25em; \/* Adjusts for spacing *\/\r\n}\r\n\r\n\/* The element to be centered, can also be of any width and height *\/ \r\n.centered {\r\n  display: inline-block;\r\n  vertical-align: middle;\r\n  width: 300px;\r\n}<\/pre>\n<pre class=\"lang:xhtml decode:true \">&lt;div class=\"block\" style=\"height: 300px;\"&gt;    \r\n    &lt;div class=\"centered\"&gt;\r\n        &lt;h1&gt;Some text&lt;\/h1&gt;\r\n        &lt;p&gt;But he stole up to us again, and suddenly clapping his hand on my shoulder, said&amp;mdash;\"Did ye see anything looking like men going towards that ship a while ago?\"&lt;\/p&gt;\r\n    &lt;\/div&gt;    \r\n&lt;\/div&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/css-tricks.com\/centering-in-the-unknown\/ \/* This parent can be any width and height *\/ .block { text-align: center; \/* May want to do this if there is risk the container may be narrower than the element inside *\/ white-space: nowrap; } \/* The ghost, nudged to maintain perfect centering *\/ .block:before { content: &#8221;; display: inline-block; height: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1029","post","type-post","status-publish","format-standard","hentry","category-websites"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/1029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=1029"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/1029\/revisions"}],"predecessor-version":[{"id":1030,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/1029\/revisions\/1030"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=1029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=1029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=1029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}