{"id":1292,"date":"2019-03-28T13:17:28","date_gmt":"2019-03-28T12:17:28","guid":{"rendered":"http:\/\/lamartinieredesign.fr\/?page_id=1292"},"modified":"2022-04-03T18:22:12","modified_gmt":"2022-04-03T16:22:12","slug":"effet-parallaxe","status":"publish","type":"page","link":"https:\/\/lamartinieredesign.fr\/?page_id=1292","title":{"rendered":"Effet Parallaxe"},"content":{"rendered":"\n<p>On peut voir de nombreux sites one-page qui font d\u00e9filer verticalement au scroll des blocs de contenu successifs semblant se passer devant l&rsquo;un l&rsquo;autre. Ces \u00ab\u00a0\u00e9crans\u00a0\u00bb occupent tout le format du viewport avec souvent une image en alternance d&rsquo;un bloc de texte.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Scroll one-page<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"697\" src=\"http:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax01-1024x697.png\" alt=\"\" class=\"wp-image-1295\" srcset=\"https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax01-1024x697.png 1024w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax01-300x204.png 300w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax01-768x523.png 768w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax01.png 1640w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"696\" src=\"http:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax02-1024x696.png\" alt=\"\" class=\"wp-image-1296\" srcset=\"https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax02-1024x696.png 1024w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax02-300x204.png 300w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax02-768x522.png 768w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax02.png 1640w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"698\" src=\"http:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax03-1024x698.png\" alt=\"\" class=\"wp-image-1297\" srcset=\"https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax03-1024x698.png 1024w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax03-300x205.png 300w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax03-768x524.png 768w, https:\/\/lamartinieredesign.fr\/wp-content\/uploads\/2019\/03\/parallax03.png 1640w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>La structure du code HTML est assez simple. Il s&rsquo;agit d&rsquo;une succession de blocs (sections, articles ou div tout simplement). Dans l&rsquo;exemple ci-dessous, j&rsquo;ai utilis\u00e9 des sections contenant uniquement du texte. Une section sur deux recevra une image d&rsquo;arri\u00e8re plan en CSS. Elles comportent toutes une classe \u00ab\u00a0ecran\u00a0\u00bb. Elles sont plac\u00e9es dans le conteneur principal &lt;<strong>main<\/strong>&gt; entre le <strong>header<\/strong> et et le <strong>footer<\/strong>, mais il pourrait en \u00eatre autrement, tout d\u00e9pend de la structure de votre code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;main id=\"content\">\n   &lt;section class=\"ecran\">\n      &lt;h1>Come To Iceland&lt;\/h1>\n   &lt;\/section>\n\n   &lt;section class=\"ecran\">\n      &lt;h2>The last settled part of Europe, much of Iceland remains pristine and untouched.&lt;\/h2>\n   &lt;\/section>\n\t\t\t\n   &lt;section class=\"ecran\">\n      &lt;h2>Population: 325,671&lt;\/h2>\n      &lt;h2>Area: 103,001km&lt;sup>2&lt;\/sup>&lt;\/h2>\n      &lt;h2>= 3 people per square km&lt;\/h2>\n   &lt;\/section>\n\n   &lt;section class=\"ecran\">\n      &lt;h2>With abundant geothermal energy, Iceland is also one of the greenest places on earth.&lt;\/h2>\n   &lt;\/section>\n\n   &lt;section class=\"ecran\">\n      &lt;h2>Come to Iceland. You\u2019ll be amazed.&lt;\/h2>\n   &lt;\/section>\n&lt;\/main><\/code><\/pre>\n\n\n\n<p>Et voici le code CSS.<br>On commence par supprimer les marges par d\u00e9faut de <strong>body<\/strong><br>Puis le gros du travail se fait dans la classe <strong>ecran<\/strong>. On r\u00e8gle d&rsquo;abord le positionnement du texte dans le bloc, par l&rsquo;alignement du texte, les marges et le positionnement flex centr\u00e9. On indique ensuite la dimension du bloc afin qu&rsquo;il occupe tout l&rsquo;espace du viewport. Enfin, on applique des r\u00e9glages de comportement des images d&rsquo;arri\u00e8re plan, fixe et plein format.<\/p>\n\n\n\n<p>Les autres r\u00e8gles s&rsquo;appliquent alternativement \u00e0 chaque section pour des mises en forme du contenu et du fond. Le fond est blanc pour les blocs pairs (even) et avec une image d&rsquo;arri\u00e8re plan pour les blocs impairs.<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>body { \n   margin: 0; \n}\n.ecran {\n   text-align: center;\n   padding: 2vw;\n   font-size: 6vw;\n\n   display: flex;\n   align-items: center;\n   justify-content: center;\n   flex-direction: column;\n\n   box-sizing: border-box;\n   height: 100vh;\n\n   background-size: cover;\n   background-repeat: no-repeat;\n   background-attachment: fixed;\n}\n.ecran:first-of-type {\n   text-transform: uppercase;\n   color: #fff;\n   font-size: 8vw;\n   text-shadow: 0 0 5px rgba(0,0,0,0.4);\n}\n.ecran:nth-of-type(even) {\n   background: #fff;\n}\n.ecran:nth-of-type(1) {\n   background-image: url(..\/media\/fond1.jpg);\n}\n.ecran:nth-of-type(3) {\n   background-image: url(..\/media\/fond2.jpg);\n}\n.ecran:nth-of-type(5) {\n   background-image: url(..\/media\/fond3.jpg);\n}<\/code><\/pre>\n\n\n\n<p>Pour m\u00e9moire, \u00ab\u00a0even\u00a0\u00bb veut dire nombre pair.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On peut voir de nombreux sites one-page qui font d\u00e9filer verticalement au scroll des blocs de contenu successifs semblant se passer devant l&rsquo;un l&rsquo;autre. Ces \u00ab\u00a0\u00e9crans\u00a0\u00bb occupent tout le format du viewport avec souvent une image en alternance d&rsquo;un bloc de texte. Scroll one-page La structure du code HTML est assez simple. Il s&rsquo;agit d&rsquo;une &hellip; <a href=\"https:\/\/lamartinieredesign.fr\/?page_id=1292\" class=\"more-link\">Continuer la lecture de <span class=\"screen-reader-text\">Effet Parallaxe<\/span>  <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":931,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"_links":{"self":[{"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=\/wp\/v2\/pages\/1292"}],"collection":[{"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1292"}],"version-history":[{"count":7,"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=\/wp\/v2\/pages\/1292\/revisions"}],"predecessor-version":[{"id":4199,"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=\/wp\/v2\/pages\/1292\/revisions\/4199"}],"up":[{"embeddable":true,"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=\/wp\/v2\/pages\/931"}],"wp:attachment":[{"href":"https:\/\/lamartinieredesign.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}