<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Forum du club des développeurs et IT Pro - Blogs - ryan</title>
		<link>https://www.developpez.net/forums/blogs/20537-ryan/</link>
		<description>Developpez.com, le Club des Développeurs et IT Pro</description>
		<language>fr</language>
		<lastBuildDate>Thu, 09 Apr 2026 20:56:30 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>15</ttl>
		<image>
			<url>https://forum.developpez.be/images/misc/rss.jpg</url>
			<title>Forum du club des développeurs et IT Pro - Blogs - ryan</title>
			<link>https://www.developpez.net/forums/blogs/20537-ryan/</link>
		</image>
		<item>
			<title>Dans la vallée, un petit effet CSS basé sur les positions relatives et absolues</title>
			<link>https://www.developpez.net/forums/blogs/20537-ryan/b258/vallee-petit-effet-css-base-positions-relatives-absolues/</link>
			<pubDate>Sun, 01 Mar 2015 16:05:45 GMT</pubDate>
			<description>Yop, 
 
Premier billet dans...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Yop,<br />
<br />
Premier billet dans ce blog, au menu un petit truc CSS: j'avais vu dans un site un design sympa où deux images s'écartaient de chaque côté de l'écran au fur et à mesure qu'on agrandissait la fenêtre, donnant l'impression d'une vallée qui s'ouvre. <br />
<br />
Le site en question était assez complexe, et je n'ai pas eu la patience de décortiquer les tonnes de CSS et Jquery pour trouver comment ils avaient fait. <br />
<br />
Je suis donc reparti &quot;from scratch&quot;. <br />
<br />
Voici deux images, droite.png et gauche.png, qui symbolisent les deux côtés de la vallée.<br />
<br />
<img src="https://www.developpez.net/forums/attachments/p170680d1425394317/systemes/linux/distributions/debat-distribution-linux-choisir-debuter/.png/" border="0" alt="Nom : droite.png
Affichages : 109
Taille : 168,7 Ko"  style="float: CONFIG" /><br />
<br />
<img src="https://www.developpez.net/forums/attachments/p170682d1425394335/systemes/linux/distributions/debat-distribution-linux-choisir-debuter/gauche.png/" border="0" alt="Nom : gauche.png
Affichages : 99
Taille : 168,8 Ko"  style="float: CONFIG" /><br />
<br />
Quand on élargit la page, ces deux cotés doivent donc rester collés respectivement aux bords gauche et droit du conteneur qui affiche le texte, ce texte doit être en sur-impression par rapport aux images. Voilà le cahier des charges.<br />
<br />
Au début, je suis parti sur une solution à base de  Jquery pour calculer les positions de mes deux versants de vallée à chaque événement resize, mais c'était d'un lourd...<br />
<br />
C'est là que j'ai compris que c'était bien plus simple. Pas besoin de javascript, rien que du CSS: tout est une histoire de position, relative ou absolue, et de z-index pour la sur-impression. Je me suis plongé dans la doc, histoire d'avoir les idées claires.<br />
<br />
Voilà le résultat: <br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code html :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td valign="top"><pre style="margin: 0">&nbsp;
<span style="color: #339933;">&lt;!DOCTYPE HTML&gt;</span>
<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">html</span><span style="color: #0000ff;">&gt;</span></span>
<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">head</span><span style="color: #0000ff;">&gt;</span></span>
<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">title</span><span style="color: #0000ff;">&gt;</span></span>vall&eacute;e<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">title</span><span style="color: #0000ff;">&gt;</span></span>
<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">head</span><span style="color: #0000ff;">&gt;</span></span>
<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">body</span> <span style="color: #0080ff;">style</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;padding: 0; margin: 0&quot;</span><span style="color: #0000ff;">&gt;</span></span>
&nbsp;
<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">div</span> <span style="color: #0080ff;">id</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;conteneur&quot;</span> <span style="color: #0080ff;">style</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;position: relative;&quot;</span><span style="color: #0000ff;">&gt;</span></span>
&nbsp;
	<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">div</span> <span style="color: #0080ff;">style</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;width: 500px; margin-left: auto; margin-right: auto; padding-bottom: 20px;&quot;</span><span style="color: #0000ff;">&gt;</span></span>
		Et eodem impetu Domitianum praecipitem per scalas itidem funibus constrinxerunt, 
		eosque coniunctos per ampla spatia civitatis acri raptavere discursu. 
		iamque artuum et membrorum divulsa conpage superscandentes corpora mortuorum ad 
		ultimam truncata deformitatem velut exsaturati mox abiecerunt in flumen.
&nbsp;
		Oportunum est, ut arbitror, explanare nunc causam, quae ad exitium praecipitem Aginatium 
		inpulit iam inde a priscis maioribus nobilem, ut locuta est pertinacior fama. nec enim 
		super hoc ulla documentorum rata est fides.
&nbsp;
		Tempore quo primis auspiciis in mundanum fulgorem surgeret victura dum erunt homines Roma, 
		ut augeretur sublimibus incrementis, foedere pacis aeternae Virtus convenit atque Fortuna 
		plerumque dissidentes, quarum si altera defuisset, ad perfectam non venerat summitatem.
&nbsp;
		Montius nos tumore inusitato quodam et novo ut rebellis et maiestati recalcitrantes Augustae 
		per haec quae strepit incusat iratus nimirum quod contumacem praefectum, quid rerum ordo postulat 
		ignorare dissimulantem formidine tenus iusserim custodiri.
&nbsp;
		Sed laeditur hic coetuum magnificus splendor levitate paucorum incondita, ubi nati sunt non 
		reputantium, sed tamquam indulta licentia vitiis ad errores lapsorum ac lasciviam. ut enim Simonides 
		lyricus docet, beate perfecta ratione vieturo ante alia patriam esse convenit gloriosam.
	<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">div</span><span style="color: #0000ff;">&gt;</span></span>
&nbsp;
	<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">div</span> <span style="color: #0080ff;">id</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;gauche&quot;</span> <span style="color: #0080ff;">style</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;position: absolute; left: 0; bottom: 0; z-index: -1; &quot;</span><span style="color: #0000ff;">&gt;</span></span>
		<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">img</span> <span style="color: #0080ff;">src</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;gauche.png&quot;</span> <span style="color: #0080ff;">alt</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;"><span style="color: #FF0000;">&quot;&quot;</span></span> /<span style="color: #0000ff;">&gt;</span></span>
	<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">div</span><span style="color: #0000ff;">&gt;</span></span>
&nbsp;
	<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">div</span> <span style="color: #0080ff;">id</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;droite&quot;</span> <span style="color: #0080ff;">style</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;position: absolute; right: 0; bottom: 0; z-index: -2; &quot;</span><span style="color: #0000ff;">&gt;</span></span>
		<span style="color: #339933;"><span style="color: #0000ff;">&lt;</span><span style="color: #0000ff;">img</span> <span style="color: #0080ff;">src</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;">&quot;droite.png&quot;</span> <span style="color: #0080ff;">alt</span><span style="color: #0000ff;">=</span><span style="color: #FF0000;"><span style="color: #FF0000;">&quot;&quot;</span></span> /<span style="color: #0000ff;">&gt;</span></span>
	<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">div</span><span style="color: #0000ff;">&gt;</span></span>	
&nbsp;
<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">div</span><span style="color: #0000ff;">&gt;</span></span>	
&nbsp;
<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">body</span><span style="color: #0000ff;">&gt;</span></span>
<span style="color: #339933;"><span style="color: #0000ff;">&lt;/</span><span style="color: #0000ff;">html</span><span style="color: #0000ff;">&gt;</span></span></pre></td></tr></table></pre>
</div><br />
Les deux côtés &quot;gauche&quot; et &quot;droit&quot; sont positionnés en &quot;absolute&quot; par rapport au conteneur. Avec les propriétés &quot;left/right&quot; et &quot;&quot;bottom&quot; à zéro pour les côtés, on s'assure qu'ils suivront le mouvement si le conteneur s'élargit, en restant respectivement dans les coins inférieurs gauche et droit du conteneur.<br />
<br />
Ce conteneur est en position &quot;relative&quot;: en effet, comme les deux côtés seront positionnés en &quot;absolute&quot; <u>par rapport au premier parent qui est lui-même positionné</u>, il est donc obligatoire de positionner le conteneur, et l'option &quot;relative&quot; fait l'affaire dans le contexte de cette page de test.<br />
<br />
Pour le reste, un peu de z-index pour gérer l'ordre des couches, un peu de formatage pour le texte, et voilà.</blockquote>

]]></content:encoded>
			<dc:creator>ryan</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/20537-ryan/b258/vallee-petit-effet-css-base-positions-relatives-absolues/</guid>
		</item>
	</channel>
</rss>
