<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Darklg Blog &#187; css</title> <atom:link href="http://blog.darklg.fr/tag/css/feed/" rel="self" type="application/rss+xml" /><link>http://blog.darklg.fr</link> <description>Intégration, développement web, SEO, caféine</description> <lastBuildDate>Tue, 31 Aug 2010 18:28:36 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Un Système de grilles/grid avec CSS &amp; PHP</title><link>http://blog.darklg.fr/339/systeme-grille-grid-css-php/</link> <comments>http://blog.darklg.fr/339/systeme-grille-grid-css-php/#comments</comments> <pubDate>Tue, 16 Mar 2010 22:38:22 +0000</pubDate> <dc:creator>darklg</dc:creator> <category><![CDATA[Développement PHP / MySQL]]></category> <category><![CDATA[Intégration xHTML / CSS]]></category> <category><![CDATA[css]]></category> <category><![CDATA[grid]]></category> <category><![CDATA[grilles]]></category> <category><![CDATA[php]]></category><guid
isPermaLink="false">http://blog.darklg.fr/?p=339</guid> <description><![CDATA[J&#8217;utilise depuis quelques mois un système de grilles léger et efficace : Le 1kb CSS GRID. Malheureusement, la version proposée sur le blog demande une reconfiguration cas par cas, et la version générée par le site dédié, demandait un retour au site pour chaque nouveau projet. J&#8217;ai donc décidé de monter un bout de code ... <a
href="http://blog.darklg.fr/339/systeme-grille-grid-css-php/">lire la suite</a>]]></description> <content:encoded><![CDATA[<p>J&#8217;utilise depuis quelques mois un système de grilles léger et efficace :<br
/> <a
href="http://www.usabilitypost.com/2009/05/29/the-1kb-css-grid-part-1/">Le 1kb CSS GRID</a>.</p><p>Malheureusement, la version  proposée sur le blog demande une reconfiguration cas par cas, et la version générée par le <a
href="http://www.1kbgrid.com/">site dédié</a>, demandait un retour au site pour chaque nouveau projet. J&#8217;ai donc décidé de monter un bout de code pour automatiser la création de grilles.<br
/> Attention, je ne gère pas de marges internes, ces dernières sont générées par les éléments contenus dans ces grilles. C&#8217;est mal, je sais.</p><p>On definit le nombre de colonnes et leur largeur par défaut.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Version A : nb_colonnes * largeur_colonne = largeur_ligne</span>
<span style="color: #000088;">$grid_nb_colonnes</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$grid_largeur</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">;</span></pre></div></div><p>Il est évidemment possible de définir la largeur totale d&#8217;une ligne :</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Version B : largeur_ligne / nb_colonnes = largeur_colonne</span>
<span style="color: #000088;">$grid_largeur_ligne</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">960</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$grid_largeur</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$grid_largeur_ligne</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$grid_nb_colonnes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Faites toutefois attention à utiliser des valeurs multiples, afin d&#8217;éviter une colonne trop petite, ou trop grande.</p><p>On génère ensuite une propriété pour chaque largeur de grille</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$grid_nb_colonnes</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'.grid_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'{width:'</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">*</span><span style="color: #000088;">$grid_largeur</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'px;} '</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div><p>On affiche les propriétés de gestion de lignes et colonnes</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'.column{float:left;overflow:hidden;display:inline;}'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'.row{width:'</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$grid_nb_colonnes</span><span style="color: #339933;">*</span><span style="color: #000088;">$grid_largeur</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'px;overflow:hidden;margin:0 auto;}'</span><span style="color: #339933;">;</span></pre></div></div><p>Et voilà <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> c&#8217;est évidemment utilisable dans mon <a
href="http://blog.darklg.fr/328/compresser-ranger-css-php/">système de compression CSS via PHP</a>, à condition de charger le contenu dans la variable $retour_css au lieu d&#8217;afficher le contenu via <strong>echo</strong>, et de l&#8217;insérer juste avant l&#8217;appel à la fonction compress();. La configuration des largeurs et colonnes peut être par contre montée en haut du script, pour plus de confort <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><p>Note : Le bout de code est sous <a
href="http://fr.wikipedia.org/wiki/WTF_Public_License">licence WTFPL</a>, mais un lien, un merci ou <a
href="https://www.amazon.fr/wishlist/1RVCWI76NZASX">un cadeau</a> (Sait-on jamais qu&#8217;un puissant mécène qui souhaite mon bonheur me lise) sont appréciés.</p><hr
/><p
style="font-size : 10px;"> Un article publi&eacute; sur <a
href="http://blog.darklg.fr">Darklg Blog</a> &copy; 2010<br
/> Lien vers l'article original : <a
href="http://blog.darklg.fr/339/systeme-grille-grid-css-php/">Un Système de grilles/grid avec CSS &amp; PHP</a><br
/> <a
rel="external nofollow" href="http://minurl.fr/?twitter&amp;titrelien=Darklg+Blog+%3A+Un+Syst%C3%A8me+de+grilles%2Fgrid+avec+CSS+%26amp%3B+PHP&amp;url=http://blog.darklg.fr/339/systeme-grille-grid-css-php/" title="Envoyer vers Twitter, avec MinURL !">Partager cet article sur Twitter</a></p>]]></content:encoded> <wfw:commentRss>http://blog.darklg.fr/339/systeme-grille-grid-css-php/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Compresser et ranger son CSS avec PHP.</title><link>http://blog.darklg.fr/328/compresser-ranger-css-php/</link> <comments>http://blog.darklg.fr/328/compresser-ranger-css-php/#comments</comments> <pubDate>Sun, 21 Feb 2010 17:19:07 +0000</pubDate> <dc:creator>darklg</dc:creator> <category><![CDATA[Développement PHP / MySQL]]></category> <category><![CDATA[Intégration xHTML / CSS]]></category> <category><![CDATA[astuce]]></category> <category><![CDATA[compresser]]></category> <category><![CDATA[css]]></category> <category><![CDATA[php]]></category><guid
isPermaLink="false">http://blog.darklg.fr/?p=328</guid> <description><![CDATA[Voici une méthode permettant de compresser des CSS, que j&#8217;utilise depuis quelques mois. Elle répond à plusieurs impératifs : Réduire le nombre de CSS chargés au minimum, pour économiser les requêtes HTTP. Permettre de créer des fichiers CSS à la volée, sans code php à l&#8217;interieur, et de les diviser le plus possible. Compresser le ... <a
href="http://blog.darklg.fr/328/compresser-ranger-css-php/">lire la suite</a>]]></description> <content:encoded><![CDATA[<p>Voici une méthode permettant de compresser des CSS, que j&#8217;utilise depuis quelques mois. Elle répond à plusieurs impératifs :</p><ul><li>Réduire le nombre de CSS chargés au minimum, pour économiser les requêtes HTTP.</li><li>Permettre de créer des fichiers CSS à la volée, sans code php à l&#8217;interieur, et de les diviser le plus possible.</li><li>Compresser le résultat.</li><li>Mettre en cache la version compressée, qui sera servie au visiteur.</li></ul><p>Cette méthode est grandement inspirée de l&#8217;article sur la <a
href="http://www.catswhocode.com/blog/3-ways-to-compress-css-files-using-php">compression des CSS chez CatsWhoCode</a>, que j&#8217;ai décortiqué pendant un bout de temps <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>On fera donc appel à ces fichiers :</p><ul><li>style.php : appelé pour créer la page, mais qui transmet également les instructions CSS.</li><li>style-min.css : Le CSS final, appelé par la version du site.</li><li>style/ : Le sous dossier contenant tous vos CSS.</li></ul><p>Les éventuelles images devront être dans le même répertoire que style.php.</p><p>Voici donc le code commenté de style.php :</p><p>On déclare le contenu comme étant du CSS, pour être sûr de son interpretation.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: text/css&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Ensuite, il faut inclure les CSS, que l&#8217;on va trier dans l&#8217;ordre alphabétique, pour permettre d&#8217;éventuels hacks, et surtout une idée de l&#8217;ordre des instructions.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// On cree une variable de retour pour contenir le CSS.</span>
<span style="color: #000088;">$retour_css</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On parcourt le sous-dossier style/</span>
<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;style/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fichiers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// On ajoute chaque fichier à un tableau 'fichiers'</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fichier</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fichier</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$fichier</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$fichiers</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'style/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$fichier</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Tri par ordre alphabetique des fichiers</span>
<span style="color: #990000;">asort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fichiers</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// inclusion des fichiers ... dans l'ordre</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fichiers</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$fichier</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000088;">$retour_css</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fichier</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>La fonction compress() va agir sur plusieurs points :</p><ul><li>Retirer les caractères &laquo;&nbsp;inutiles&nbsp;&raquo;, comme les commentaires, tabulations, et transformer les espaces multiples en espaces simples, etc.</li><li>Permettre la mise en place d&#8217;un léger système de variables. Utile si vous avez beaucoup de fichiers <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></li></ul><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> compress<span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$variables_css</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'COULEUR1'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'#003366'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'COULEUR2'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'#336699'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'FONT1'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Georgia, serif'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// On remplace les variables par leur valeur</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variables_css</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$code_variable</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$valeur</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{'</span><span style="color: #339933;">.</span><span style="color: #000088;">$code_variable</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'}'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$valeur</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Suppression des commentaires</span>
	<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!/\*[^*]*\*+([^/][^*]*\*+)*/!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Suppression des tabulations, espaces multiples, retours à la ligne, etc.</span>
	<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'  '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'	 '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'	 '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Suppression des derniers espaces inutiles</span>
	<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' { '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">' {'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'{ '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'{'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' } '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">' }'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'} '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'}'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' : '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">' :'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">': '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">':'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$buffer</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Compression du CSS</span>
<span style="color: #000088;">$retour_css</span> <span style="color: #339933;">=</span> compress<span style="color: #009900;">&#40;</span><span style="color: #000088;">$retour_css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Enfin, nous allons mettre en cache le contenu de la variable $retour_css, et l&#8217;afficher, pour les tests.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Mise en cache du fichier style-min.css</span>
<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'style-min.css'</span><span style="color: #339933;">,</span><span style="color: #000088;">$retour_css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// On affiche le contenu compressé</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$retour_css</span><span style="color: #339933;">;</span></pre></div></div><p>Vous pouvez créer autant de fichiers CSS que vous le désirez dans le sous-dossier style/, afin de séparer couleurs, tailles, réglages de base, Reset CSS et autres grilles.</p><p>Vous m&#8217;avez lu jusqu&#8217;ici ? Woah <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Apprenez donc que ce code est sous licence <a
href="http://fr.wikipedia.org/wiki/WTF_Public_License">WTFPL</a>, qu&#8217;un lien vers cet article sera accueilli avec grand bonheur, et qu&#8217;un commentaire constructif le sera également <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><hr
/><p
style="font-size : 10px;"> Un article publi&eacute; sur <a
href="http://blog.darklg.fr">Darklg Blog</a> &copy; 2010<br
/> Lien vers l'article original : <a
href="http://blog.darklg.fr/328/compresser-ranger-css-php/">Compresser et ranger son CSS avec PHP.</a><br
/> <a
rel="external nofollow" href="http://minurl.fr/?twitter&amp;titrelien=Darklg+Blog+%3A+Compresser+et+ranger+son+CSS+avec+PHP.&amp;url=http://blog.darklg.fr/328/compresser-ranger-css-php/" title="Envoyer vers Twitter, avec MinURL !">Partager cet article sur Twitter</a></p>]]></content:encoded> <wfw:commentRss>http://blog.darklg.fr/328/compresser-ranger-css-php/feed/</wfw:commentRss> <slash:comments>49</slash:comments> </item> <item><title>12 principes pour garder un code propre</title><link>http://blog.darklg.fr/158/12-principes-pour-garder-un-code-propre/</link> <comments>http://blog.darklg.fr/158/12-principes-pour-garder-un-code-propre/#comments</comments> <pubDate>Thu, 13 Nov 2008 16:18:12 +0000</pubDate> <dc:creator>darklg</dc:creator> <category><![CDATA[Intégration xHTML / CSS]]></category> <category><![CDATA[code]]></category> <category><![CDATA[css]]></category> <category><![CDATA[xhtml]]></category><guid
isPermaLink="false">http://blog.darklg.fr/?p=158</guid> <description><![CDATA[Je suis tombé hier soir sur un excellent article de Smashing Magazine intitulé &#171;&#160;12 Principles For Keeping Your Code Clean&#171;&#160;. Ce sont 12 étapes assez simples pour avoir un code propre et réutilisable / exploitable par d&#8217;autres webmasters / intégrateurs / etc. Voici une adaptation en français, pour ceux qui n&#8217;auraient pas le temps de ... <a
href="http://blog.darklg.fr/158/12-principes-pour-garder-un-code-propre/">lire la suite</a>]]></description> <content:encoded><![CDATA[<p>Je suis tombé hier soir sur un excellent article de Smashing Magazine intitulé &laquo;&nbsp;<a
href="http://www.smashingmagazine.com/2008/11/12/12-principles-for-keeping-your-code-clean/">12 Principles For Keeping Your Code Clean</a>&laquo;&nbsp;.<br
/> Ce sont 12 étapes assez simples pour avoir un code propre et réutilisable / exploitable par d&#8217;autres webmasters / intégrateurs / etc. Voici une adaptation en français, pour ceux qui n&#8217;auraient pas le temps de se plonger dans l&#8217;article original.</p><h3>1. Choisissez un Doctype STRICT</h3><p>On ne va pas revenir sur la guerre ancestrale entre HTML 4.01 et xHTML 1.0. Les deux possèdent une version stricte, vous obligeant à rédiger du code correct.</p><h3>2. Utilisez des caractères encodés comme &amp;amp;</h3><p>Pour commencer, assurez-vous d&#8217;utiliser un charset UTF-8</p><div
class="wp_syntax"><div
class="code"><pre class="xhtml" style="font-family:monospace;">&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;</pre></div></div><p>Ensuite, assurez vous que les caractères comme &amp; soient bien écrits &nbsp;&raquo; &amp;amp; &laquo;&nbsp;.<br
/> De même pour les lettres accentuées, comme é : &nbsp;&raquo; &amp;eacute; &nbsp;&raquo; ou à : &nbsp;&raquo; &amp;agrave; &nbsp;&raquo;</p><h3>3. Indentez correctement votre code</h3><p>Ok, l&#8217;indentation n&#8217;a -quasiment- aucune influence sur le rendu final de la page, mais le gain en lisibilité est tel que ça vaut carrément le coup. La procédure standard veut que vous indentiez d&#8217;une tabulation, ou de quelques espaces, quand vous ouvrez un nouvel élément enfant de l&#8217;élément au dessus. Puis ensuite, de revenir d&#8217;une tabulation en arrière lors de la fermeture de cet élément.<br
/> Evidemment, rien d&#8217;obligatoire ni de figé. Ce qui est le plus lisible, et le plus simple à interprêter sera le meilleur <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><h3>4. Gardez vos CSS et Javascript hors du fichier.</h3><p>Les balises &lt;style /&gt;, &lt;script /&gt;, et autres attributs style=&nbsp;&raquo;" devraient être réduits au minimum, et leur contenant externalisé. En effet, il est plus simple d&#8217;appeler une seule feuille de style, que d&#8217;en maintenir une par page. De même pour les scripts. Certains navigateurs bien réglés les garderont en cache, évitant ainsi des téléchargements inutiles.</p><h3>5. Organisez correctement vos balises</h3><p>Un élément de type &laquo;&nbsp;inline&nbsp;&raquo; doit être dans un élément de type &laquo;&nbsp;block&nbsp;&raquo;.<br
/> Vous voulez faire un lien sur le titre de votre site ?<br
/> Ecrivez le comme ceci :</p><div
class="wp_syntax"><div
class="code"><pre class="xhtml" style="font-family:monospace;">&lt;h1&gt;&lt;a href=&quot;http://blog.darklg.fr&quot;&gt;Darklg Blog&lt;/a&gt;&lt;/h1&gt;</pre></div></div><p>Et non comme ça :</p><div
class="wp_syntax"><div
class="code"><pre class="xhtml" style="font-family:monospace;">&lt;a href=&quot;http://blog.darklg.fr&quot;&gt;&lt;h1&gt;Darklg Blog&lt;/h1&gt;&lt;/a&gt;</pre></div></div><h3>6. Eliminez les DIV inutiles.</h3><p>Gardez ça en tête : Une flopée de DIV ne vaut pas mieux qu&#8217;un design en tableau.<br
/> Il est possible de styliser un h1, un ul, ou la plupart des éléments de type block aussi bien qu&#8217;un DIV.</p><h3>7. Choisissez de meilleurs conventions de noms</h3><p>Ok, c&#8217;est sûrement très facile de nommer cette classe BleuGras, mais qui vous dit que demain, un client ne vous demandera pas de changer tout ça en Vert et Italique ?<br
/> Des idées de noms de classes : Entete, Pied, Footer, Navigation, Menu, Sidebar, Principal, Secondaire &#8230;<br
/> Vous pouvez évidemment les combiner : EnteteNavigation, MenuSecondaire, etc etc &#8230;</p><h3>8. Laissez CSS gérer la typographie.</h3><p>Il est peut-être plus évident d&#8217;écrire UN TEXTE EN CAPITALES, mais il est beaucoup plus simple, pour l&#8217;évolutivité de votre code, de faire appel à la propriété CSS text-transform :</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">h1 <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">text-transform</span> <span style="color: #00AA00;">:</span> <span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><h3>9. Ajoutez de la class à votre &lt;body&gt;</h3><p>Au delà du jeu de mots pourri, il est assez intéressant d&#8217;ajouter différents styles, à travers un attribut class, ou id, à l&#8217;élément body. Selon le style à adopter sur vos pages, par exemple menu à gauche, ou à droite &#8230;</p><h3>10. Validez votre code.</h3><p>Si vous développez sous Firefox et que vous avez la &nbsp;&raquo; flemme &laquo;&nbsp;, ou l&#8217;impossibilité de soumettre vos pages au validateur xhtml/css du W3C ( codage hors-ligne, en local, etc ), je vous conseille l&#8217;extension HTML Validator, qui vous offrira une validation au fur et à mesure de votre travail.<br
/> Attention, on devient vite accro au résultat &nbsp;&raquo; 0 erreurs / 0 avertissements &laquo;&nbsp;. <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><h3>11. Gardez un ordre logique</h3><p>On ne le dira jamais assez, ordonner vos éléments de manière logique est primordial. Un header doit être dans le haut d&#8217;une page, et un footer dans le bas. Certains navigateurs n&#8217;affichant pas ( ou mal ) les feuilles de styles vous feraient regretter le choix contraire. Comme le navigateur de votre portable presque-next-gen, par exemple.</p><h3>12. Faites ce que vous pouvez</h3><p>Quand on écrit du code depuis le début, c&#8217;est plutôt simple d&#8217;adapter ces conseils. Malheureusement, c&#8217;est beaucoup plus dur lorsqu&#8217;on tombe sur un code source datant de l&#8217;âge de pierre ( ou plutôt de Frontpage 1.0 ). Si vous êtes bloqués par cette erreur provoquée par une sombre fonctionnalité de WordPress, et qu&#8217;il est impossible, ou presque, de modifier, tant pis. L&#8217;important, c&#8217;est avant tout de vouloir coder proprement, et de faire de son mieux <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p><strong>Note de Darklg</strong> : <em>J&#8217;essaie moi même de me tenir à la plupart de ces conseils, mais il y a des fois où, pour telle ou telle raison, ce n&#8217;est pas possible. Les conseils que je pourrais rajouter seraient alors :</em></p><h3>13. Utilisez le moins de hacks possible</h3><p>Même s&#8217;ils sont souvent des recettes magiques pour réduire des incompatibilités entre navigateurs, les bidouilles sont très rarement évolutives. Pourquoi pas en cas d&#8217;énorme blocages, mais évitez les quand vous pouvez <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><h3>14. Ne jamais hésiter à demander un avis extérieur.</h3><p>Que ce soit sur Twitter, sur des Forums, sur des Groupes, auprès de développeurs expérimentés, ou même en soirée codeurs, une question posée au bon endroit, ou un terme recherché intelligemment sur Google, vous sortira souvent d&#8217;un immense pétrin.</p><p><em>Cet article est plus une adaptation à ma sauce qu&#8217;une véritable traduction. N&#8217;hésitez pas à me signaler toute erreur ou toute faute de goût dans <a
href="http://blog.darklg.fr/158/12-principes-pour-garder-un-code-propre/">les commentaires</a> <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p><p>Note : N&#8217;hésitez pas à lire cet article de Dame Tartine, qui achèvera de vous convaincre  : <a
href="http://www.quatuorprod.com/blog/partage/code-propre-et-proprete-du-code-41">Code propre et propreté du code</a></p><hr
/><p
style="font-size : 10px;"> Un article publi&eacute; sur <a
href="http://blog.darklg.fr">Darklg Blog</a> &copy; 2010<br
/> Lien vers l'article original : <a
href="http://blog.darklg.fr/158/12-principes-pour-garder-un-code-propre/">12 principes pour garder un code propre</a><br
/> <a
rel="external nofollow" href="http://minurl.fr/?twitter&amp;titrelien=Darklg+Blog+%3A+12+principes+pour+garder+un+code+propre&amp;url=http://blog.darklg.fr/158/12-principes-pour-garder-un-code-propre/" title="Envoyer vers Twitter, avec MinURL !">Partager cet article sur Twitter</a></p>]]></content:encoded> <wfw:commentRss>http://blog.darklg.fr/158/12-principes-pour-garder-un-code-propre/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>3 astuces CSS fort utiles</title><link>http://blog.darklg.fr/20/3-astuces-css/</link> <comments>http://blog.darklg.fr/20/3-astuces-css/#comments</comments> <pubDate>Mon, 02 Jun 2008 13:54:53 +0000</pubDate> <dc:creator>darklg</dc:creator> <category><![CDATA[Intégration xHTML / CSS]]></category> <category><![CDATA[astuce]]></category> <category><![CDATA[astuces]]></category> <category><![CDATA[class]]></category> <category><![CDATA[css]]></category> <category><![CDATA[reset]]></category><guid
isPermaLink="false">http://blog.darklg.fr/?p=20</guid> <description><![CDATA[Voici quelques astuces CSS assez utiles, mais très peu utilisées. Au menu : Bien utiliser &#60;HTML&#62; et &#60;BODY&#62; Appliquer un style à tous les éléments. Donner plusieurs &#171;&#160;class&#160;&#187; à un élément Bien utiliser &#60;HTML&#62; et &#60;BODY&#62; &#60;HTML&#62;, comme tout autre élément, peut être personnalisé via les CSS. Par exemple, on peut lui ajouter un background, ... <a
href="http://blog.darklg.fr/20/3-astuces-css/">lire la suite</a>]]></description> <content:encoded><![CDATA[<p>Voici quelques <strong>astuces CSS</strong> assez utiles, mais très peu utilisées.<br
/> Au menu :</p><ul><li>Bien utiliser &lt;HTML&gt; et &lt;BODY&gt;</li><li>Appliquer un style à tous les éléments.</li><li>Donner plusieurs &laquo;&nbsp;class&nbsp;&raquo; à un élément</li></ul><h3>Bien utiliser &lt;HTML&gt; et &lt;BODY&gt;</h3><p>&lt;HTML&gt;, comme tout autre élément, peut être personnalisé via les CSS.<br
/> Par exemple, on peut lui ajouter un background, un margin ou autre.<br
/> &lt;BODY&gt;, quant à lui, est interprété par la plupart des navigateurs comme un élément de type block.<br
/> Cette astuce implique donc de bien réfléchir à la nécessité d&#8217;utiliser un block type &laquo;&nbsp;mapage&nbsp;&raquo;, ou &laquo;&nbsp;tout&nbsp;&raquo; comme j&#8217;ai (trop) souvent trouvé dans des templates <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><h3>Appliquer un style à tous les éléments.</h3><p>Il est possible d&#8217;appliquer un style général à tous les éléments, via *<br
/> Cette technique est utilisée par certaines feuilles de <a
href="http://blog.alsacreations.com/2007/07/02/369-reset-css-une-technique-a-manier-avec-precaution">Reset CSS</a>, pour appliquer des marges intérieurs et extérieures de 0 par défaut sur tous les éléments.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span>	<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span>	<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><h3>Donner plusieurs &laquo;&nbsp;class&nbsp;&raquo; à un élément</h3><p>Il est possible de donner plusieurs valeurs à un attribut class, ce qui permet de gérer plus proprement certains éléments.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* CSS */</span>
<span style="color: #6666ff;">.rose</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">color</span>	<span style="color: #00AA00;">:</span> pink<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.souligne</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span>	<span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><div
class="wp_syntax"><div
class="code"><pre class="html" style="font-family:monospace;">&lt;em class=&quot;rose souligne&quot;&gt;texte rose et souligné&lt;/em&gt;</pre></div></div><p>avec comme résultat &laquo;&nbsp;<em
style="color:pink;text-decoration:underline;">texte rose et souligné</em>&laquo;&nbsp;.<br
/> edit : comme l&#8217;a noté <a
href="http://www.kazhar.org">Kazhar</a> dans les commentaires, il faut nommer ses classes CSS en fonction de l&#8217;utilité de l&#8217;élément, mais pour le coup, il me fallait un exemple facile à comprendre, et à expliquer <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><p>En espérant que ces <strong>3 astuces en CSS</strong> vous aient été utiles <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><hr
/><p
style="font-size : 10px;"> Un article publi&eacute; sur <a
href="http://blog.darklg.fr">Darklg Blog</a> &copy; 2010<br
/> Lien vers l'article original : <a
href="http://blog.darklg.fr/20/3-astuces-css/">3 astuces CSS fort utiles</a><br
/> <a
rel="external nofollow" href="http://minurl.fr/?twitter&amp;titrelien=Darklg+Blog+%3A+3+astuces+CSS+fort+utiles&amp;url=http://blog.darklg.fr/20/3-astuces-css/" title="Envoyer vers Twitter, avec MinURL !">Partager cet article sur Twitter</a></p>]]></content:encoded> <wfw:commentRss>http://blog.darklg.fr/20/3-astuces-css/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Transcender CSS &#8211; Andy Clarke</title><link>http://blog.darklg.fr/12/transcender-css-andy-clarke/</link> <comments>http://blog.darklg.fr/12/transcender-css-andy-clarke/#comments</comments> <pubDate>Sun, 18 May 2008 13:29:40 +0000</pubDate> <dc:creator>darklg</dc:creator> <category><![CDATA[Lectures]]></category> <category><![CDATA[css]]></category> <category><![CDATA[livre]]></category> <category><![CDATA[transcender]]></category><guid
isPermaLink="false">http://blog.darklg.fr/?p=12</guid> <description><![CDATA[Transcender CSS est un de ces livres qui vous font avancer dans votre façon de concevoir des pages Web. Andy Clarke, l&#8217;auteur de ces pages, est un webdesigner anglais particulièrement créatif qui a rassemblé dans ce livre les meilleures techniques pour utiliser les CSS. Il y donne également d&#8217;excellents conseils concernant l&#8217;utilisation des grilles pour ... <a
href="http://blog.darklg.fr/12/transcender-css-andy-clarke/">lire la suite</a>]]></description> <content:encoded><![CDATA[<p
style="text-align:center;"><a
href="http://www.flickr.com/photos/darklg/2501145825/" title="Transcender CSS"><img
src="http://farm3.static.flickr.com/2391/2501145825_a708dc15ed_m.jpg" alt="Transcender CSS - Andy Clarke" /></a></p><p><strong>Transcender CSS</strong> est un de ces livres qui vous font avancer dans votre façon de concevoir des pages Web. <strong><a
href="http://www.stuffandnonsense.co.uk">Andy Clarke</a></strong>, l&#8217;auteur de ces pages, est un webdesigner anglais particulièrement créatif qui a rassemblé dans ce livre les meilleures techniques pour utiliser les CSS.</p><p>Il y donne également d&#8217;excellents conseils concernant<strong> l&#8217;utilisation des grilles pour le design</strong>, du <strong><a
href="http://fr.wikipedia.org/wiki/Nombre_d'or">nombre d&#8217;or</a></strong>, et des explications concernant les<strong> nouveautés apportées par CSS 3</strong>.</p><p>Ses recommandations concernant l&#8217;usage des <strong><a
href="http://microformats.org/wiki/Main_Page-fr">microformats</a></strong>, ou de la <strong><a
href="http://openweb.eu.org/articles/respecter_semantique/">sémantique xHTML</a></strong>, sont dignes d&#8217;être rappelées, et accompagnées d&#8217;explications simples à comprendre. L&#8217;auteur recommande en effet de penser le design et les balises utilisées en fonction du contenu, contrairement à certains webmasters moins scrupuleux, utilisant un template récupéré et utilisé abusivement de nombreuses fois auparavant.</p><p>Le livre contient également de nombreuses illustrations choisies sur <a
href="http://www.flickr.com">Flickr</a>, rendant la consultation très agréable, apportant des touches d&#8217;inspiration fort utiles <img
src='http://blog.darklg.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p><p><strong>Malgré ces qualités</strong>, je n&#8217;ai pas accroché sur l&#8217;<strong>utilisation systématique du positionnement absolu</strong> pour ses créations, ou encore la recommandation d&#8217;<strong>optimiser son code pour les navigateurs récents</strong>, au détriment des vieilles machines utilisant encore Internet Explorer 6 et consors. C&#8217;est un petit détail qui fâche beaucoup de webmasters, et je ne suis pas de l&#8217;avis de l&#8217;auteur, privilégiant pour ma part un rendu plus ou moins ressemblant (<em> l&#8217;identique étant impossible à retrouver</em> ) sur toutes les configurations.</p><p>Pour conclure, un excellent livre pour trouver de l&#8217;inspiration, et comprendre certains impératifs esthétiques, ou encore comprendre la nécessité de coder de manière sémantique. <strong>Un livre à lire absolument !</strong></p><hr
/><p
style="font-size : 10px;"> Un article publi&eacute; sur <a
href="http://blog.darklg.fr">Darklg Blog</a> &copy; 2010<br
/> Lien vers l'article original : <a
href="http://blog.darklg.fr/12/transcender-css-andy-clarke/">Transcender CSS &#8211; Andy Clarke</a><br
/> <a
rel="external nofollow" href="http://minurl.fr/?twitter&amp;titrelien=Darklg+Blog+%3A+Transcender+CSS+%26%238211%3B+Andy+Clarke&amp;url=http://blog.darklg.fr/12/transcender-css-andy-clarke/" title="Envoyer vers Twitter, avec MinURL !">Partager cet article sur Twitter</a></p>]]></content:encoded> <wfw:commentRss>http://blog.darklg.fr/12/transcender-css-andy-clarke/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)

Served from: blog.darklg.fr @ 2010-09-10 11:48:36 -->