{"id":1466,"date":"2026-02-16T22:51:43","date_gmt":"2026-02-16T22:51:43","guid":{"rendered":"https:\/\/mytribu.fr\/cmopc\/?p=1466"},"modified":"2026-02-20T00:52:41","modified_gmt":"2026-02-20T00:52:41","slug":"centrage","status":"publish","type":"post","link":"http:\/\/mytribu.fr\/cmopc\/centrage\/","title":{"rendered":"CSS centrage du body"},"content":{"rendered":"\n\n\n<pre class=\"wp-block-code\"><code>body {\n    background-color: #000000;\n    margin: 0;\n    height: 100vh;\n    display: flex;\n    flex-direction:column; \/* centre en colonne mettre flex-direction: row; pour centrer en ligne *\/\n    justify-content: center;   \/* centre horizontalement *\/\n    align-items: center;       \/* centre verticalement *\/\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Explication du code<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f539; <code>background-color: #000000;<\/code><\/h3>\n\n\n\n<p>D\u00e9finit un fond noir pour la page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f539; <code>margin: 0;<\/code><\/h3>\n\n\n\n<p>Supprime les marges automatiques appliqu\u00e9es par le navigateur au <code>body<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f539; <code>height: 100vh;<\/code><\/h3>\n\n\n\n<p><code>vh<\/code> signifie <em>viewport height<\/em>.<br><code>100vh<\/code> correspond \u00e0 100% de la hauteur visible de l\u2019\u00e9cran.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f539; <code>display: flex;<\/code><\/h3>\n\n\n\n<p>Active le mod\u00e8le <strong>Flexbox<\/strong>, qui permet d\u2019aligner facilement des \u00e9l\u00e9ments.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f539; <code>justify-content: center;<\/code><\/h3>\n\n\n\n<p>Centre le contenu sur l\u2019axe horizontal (gauche &#x2194; droite).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f539; <code>align-items: center;<\/code><\/h3>\n\n\n\n<p>Centre le contenu sur l\u2019axe vertical (haut &#x2195; bas).<\/p>\n\n\n\n<p><strong>Change le fond noir en d\u00e9grad\u00e9 :<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>background: linear-gradient(135deg, #000, #222);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Explication du code &#x1f539; background-color: #000000; D\u00e9finit un fond noir pour la page. &#x1f539; margin: 0; Supprime les marges automatiques<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1466","post","type-post","status-publish","format-standard","hentry","category-non-classe","comments-off"],"_links":{"self":[{"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/posts\/1466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/comments?post=1466"}],"version-history":[{"count":9,"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/posts\/1466\/revisions"}],"predecessor-version":[{"id":1549,"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/posts\/1466\/revisions\/1549"}],"wp:attachment":[{"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/media?parent=1466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/categories?post=1466"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mytribu.fr\/cmopc\/wp-json\/wp\/v2\/tags?post=1466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}