<?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>Avivo Tech Blog &#187; html</title>
	<atom:link href="http://tech.avivo.si/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.avivo.si</link>
	<description>Solving problems</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Very cool! Create TRIANGLE in HTML with CSS</title>
		<link>http://tech.avivo.si/2011/08/very-cool-create-triangle-in-html-with-css/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=very-cool-create-triangle-in-html-with-css</link>
		<comments>http://tech.avivo.si/2011/08/very-cool-create-triangle-in-html-with-css/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 10:46:55 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[shape]]></category>
		<category><![CDATA[triangle]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1367</guid>
		<description><![CDATA[.triangle { border-bottom: 100px solid #FC2E5A; border-left: 50px solid transparent; border-right: 50px solid transparent; height: 0; width: 0; } .infinity { position: relative; width: 212px; height: 100px; } .infinity:before, .infinity:after { content: ""; position: absolute; top: 0; left: 0; width: 60px; height: 60px; border: 20px solid #fc2e5a; -moz-border-radius: 50px 50px 0 50px; border-radius: 50px 50px [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
.triangle {
border-bottom: 100px solid #FC2E5A;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
height: 0;
width: 0;
}
.infinity {
    position: relative;
    width: 212px;
    height: 100px;
}
.infinity:before,
.infinity:after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 60px;    
    border: 20px solid #fc2e5a;
    -moz-border-radius: 50px 50px 0 50px;
         border-radius: 50px 50px 0 50px;
    -webkit-transform: rotate(-45deg);
       -moz-transform: rotate(-45deg);
        -ms-transform: rotate(-45deg);
         -o-transform: rotate(-45deg);
            transform: rotate(-45deg);
}
.infinity:after {
    left: auto;
    right: 0;
    -moz-border-radius: 50px 50px 50px 0;
         border-radius: 50px 50px 50px 0;
    -webkit-transform:rotate(45deg);
       -moz-transform:rotate(45deg);
        -ms-transform:rotate(45deg);
         -o-transform:rotate(45deg);
            transform:rotate(45deg);
}
</style>
<h2>Triangle in pure HTML/CSS</h2>
<div class="triangle"></div>
<h2>Infinity in pure HTML/CSS</h2>
<div class="infinity"></div>
<div style="margin-top: 25px; margin-bottom: 25px;">So, this is the CSS for triangle:</div>
<pre>.triangle {
    border-bottom: 100px solid #FC2E5A;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    height: 0;
    width: 0;
}</pre>
<div style="margin-top: 25px; margin-bottom: 25px;">
All other <a title="Custom shapes in HTML" href="http://3easy.org/buildmobile/jquerymobile/" target="_blank">custom shapes</a>!
</div>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/08/very-cool-create-triangle-in-html-with-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preloading images with JavaScript (JQuery) and JQuery cool animations and effects</title>
		<link>http://tech.avivo.si/2011/01/preloading-images-with-javascript-jquery-and-jquery-animations-and-effect/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=preloading-images-with-javascript-jquery-and-jquery-animations-and-effect</link>
		<comments>http://tech.avivo.si/2011/01/preloading-images-with-javascript-jquery-and-jquery-animations-and-effect/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 16:29:02 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[animations]]></category>
		<category><![CDATA[client side]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery animations]]></category>
		<category><![CDATA[jquery effects]]></category>
		<category><![CDATA[preloading images with javascript]]></category>
		<category><![CDATA[preloading images with jquery]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1132</guid>
		<description><![CDATA[Model 1: &#60;img src="images/blank.gif" onload="replaceImage(this, 'your-image-url')" width="75" height="75" /&#62; Use function to replaceImage: function replaceImage(img, replacementImage) { img.onload = null; img.src = replacementImage; } blank.gif is an 1px x 1px pixel transparent image. Basically, the idea is that this blank image is loaded and expanded to 75&#215;75 (to preserve layout). That almost immediately fires the [...]]]></description>
			<content:encoded><![CDATA[<h3><strong>Model 1:</strong></h3>
<pre class="html">&lt;img src="images/blank.gif" onload="replaceImage(this, 'your-image-url')" width="75" height="75" /&gt;
</pre>
<p>Use function to replaceImage:</p>
<pre class="javascript">function replaceImage(img, replacementImage)
{
  img.onload = null;
  img.src = replacementImage;
}
</pre>
<p>blank.gif is an 1px x 1px  pixel transparent image. Basically, the idea is that this blank image is loaded and expanded to 75&#215;75 (to preserve layout). That almost immediately fires the onload handler, which changes the image&#8217;s source to the desired image.</p>
<h3><strong>Model 2:</strong></h3>
<pre class="javascript">var img = new Image();
img.onError = function(){
  //error handling here
}
img.onLoad = function(){
  //success
containerForImg.removeClass('loading-image').append($(img));
}
img.onAbort = function(){
  //user clicked stop
}
img.src = "http://example.com"   //loading begins NOW!
</pre>
<h3><strong>References:</strong></h3>
<p><a href="http://goo.by/wE3TFa" target="_blank">http://goo.by/wE3TFa</a><br />
<a href="http://goo.by/w7AjZN" target="_blank">http://goo.by/w7AjZN</a><br />
<a href="http://goo.by/w0CsbA" target="_blank">http://goo.by/w0CsbA</a></p>
<h3><strong>Background image animations:</strong></h3>
<pre class="css">$('#nav a')
.css( {backgroundPosition: "0 0"} )
.mouseover(function(){
$(this).stop().animate(
{backgroundPosition:"(0 -250px)"},
{duration:500})
})
.mouseout(function(){
$(this).stop().animate(
{backgroundPosition:"(0 0)"},
{duration:500})
})
</pre>
<h3><strong>Background transitions:</strong></h3>
<p><a href="http://goo.by/wIJ6iD" target="_blank">http://goo.by/wIJ6iD</a></p>
<h3><strong>Cool JQuery Animated robot:</strong></h3>
<p>TUTORIAL: <a href="http://goo.by/w4znKB" target="_blank">http://goo.by/w4znKB</a><br />
DEMO: <a href="http://goo.by/wmSMKs" target="_blank">http://goo.by/wmSMKs</a></p>
<h3><strong>Nice login page:</strong></h3>
<p>TUTORIAL: <a href="http://goo.by/wBrnQi" target="_blank">http://goo.by/wBrnQi</a><br />
DEMO: <a href="http://goo.by/wdgmT1" target="_blank">http://goo.by/wdgmT1</a></p>
<h3><strong>Loading content:</strong></h3>
<p>TUTORIAL: <a href="http://goo.by/wn53Y0" target="_blank">http://goo.by/wn53Y0</a><br />
DEMO: <a href="http://goo.by/wTGKDx" target="_blank">http://goo.by/wTGKDx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/01/preloading-images-with-javascript-jquery-and-jquery-animations-and-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to trim leading and trailing HTML spaces in C#</title>
		<link>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-trim-leading-and-trailing-html-spaces-in-c</link>
		<comments>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 12:27:52 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[remove trailing and leading html spaces]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=948</guid>
		<description><![CDATA[Some HTML WYSIWYG editors create &#8216;br&#8217; tags or leave &#8216;&#38;nbsp;&#8217; garbage spaces when no content is entered. Described TrimWhiteSpaces method is useful when you need to determine if user left blank content in WYSIWYG editor or if you just want to clean HTML code. TrimWhiteSpaces accepts raw HTML content and removes white spaces, tabs, new [...]]]></description>
			<content:encoded><![CDATA[<p>Some HTML WYSIWYG editors create &#8216;br&#8217; tags or leave &#8216;&amp;nbsp;&#8217; garbage spaces when no content is entered. Described <strong>TrimWhiteSpaces </strong>method is useful when you need to determine if user left blank content in WYSIWYG editor or if you just want to clean HTML code.</p>
<p><strong>TrimWhiteSpaces</strong> accepts raw HTML content and removes white spaces, tabs, new line characters, &#8216;br&#8217; tags and &#8216;&amp;nbsp;&#8217; chunks from before and after the actual content.</p>
<pre class=csharp>
public static string TrimWhiteSpaces(string html)
{
  string result = html;

  //Remove leading spaces
  result = Regex.Replace(result, @"<span style="color: red;">^(?&lt;leading&gt;(\s|\r|\n|\&lt;br\s*/?\&gt;|&amp;nbsp;)*)</span>", "",
RegexOptions.IgnoreCase);

  //Remove trailing spaces
  result = Regex.Replace(result, @"<span style="color: red;">(?&lt;trailing&gt;(\s|\r|\n|\&lt;br\s*/?\&gt;|&amp;nbsp;)*)$</span>", "",
RegexOptions.IgnoreCase);

  return result;
}
</pre>
<div style="margin-top:20px;">
<strong>Example:</strong>
</div>
<div style="margin-top:20px;">
<strong>Input:</strong></p>
<pre><span style="color: red;">&amp;nbsp;&lt;br /&gt;&lt;BR   &gt;&lt;BR&gt; &amp;nbsp;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;</span><span style="color: blue;">
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;p&gt;Pellentesque lorem neque, accumsan eget euismod ut, tristique et odio.&lt;/p&gt;</span>
<span style="color: red;">&amp;nbsp;&lt;br /&gt; &lt;br&gt;
&amp;nbsp;</span>
</pre>
</div>
<div style="margin-top:20px;">
<strong>Output:</strong></p>
<pre class=csharp>
<span style="color: blue;">
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;p&gt;Pellentesque lorem neque, accumsan eget euismod ut, tristique et odio.&lt;/p&gt;
</span>
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detect Browser in CSS</title>
		<link>http://tech.avivo.si/2010/08/detect-browser-in-css/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=detect-browser-in-css</link>
		<comments>http://tech.avivo.si/2010/08/detect-browser-in-css/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 12:07:09 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[browser detection]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[detect browser in css]]></category>
		<category><![CDATA[detect internet explorer version in css]]></category>
		<category><![CDATA[how to detect browser version in css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=564</guid>
		<description><![CDATA[Sometimes you need to detect browser version in CSS in order to apply additional, browser specific, properties to the same class. Here are the ways for selecting specific versions of Internet Explorer by using followind conditional comments: IE 6 and below Use * html {} to select the html element. IE 7 and below Use [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to detect browser version in CSS in order to apply additional, browser specific, properties to the same class.</p>
<p>Here are the ways for selecting specific versions of Internet Explorer by using followind conditional comments:</p>
<ul>
<li>
<h3><strong>IE 6 and below</strong></h3>
<ul>
<li>Use <strong><span style="color: #800000;">* html {}</span></strong> to select the html element.</li>
</ul>
</li>
<li>
<h3><strong>IE 7 and below</strong></h3>
<ul>
<li>Use <strong><span style="color: #800000;">*:first-child+html {} * html {} </span></strong>to select the html element.</li>
</ul>
</li>
<li>
<h3><strong>IE 7 only</strong></h3>
<ul>
<li>Use <strong><span style="color: #800000;">*:first-child+html {}</span></strong> to select the html element.</li>
</ul>
</li>
<li>
<h3><strong>IE 7 and modern browsers only</strong></h3>
<ul>
<li>Use <strong><span style="color: #800000;">html&gt;body {}</span></strong> to select the body element.</li>
</ul>
</li>
<li>
<h3><strong>Modern browsers only (not IE 7)</strong></h3>
<ul>
<li>Use<strong><span style="color: #800000;"> html&gt;/**/body {}</span></strong> to select the body element.</li>
</ul>
</li>
</ul>
<p>Example for <strong>IE7 only (</strong><span style="color: #800000;">change left padding to 5px instead of 20px as it is for other browsers</span>)</p>
<pre lang="css"><span style="color: #800000;">.your_css_class
{
	color: #000;
	padding: 20px;
	background: #fff;
}

/* IE7 hack */
*:first-child+html .your_css_class
{
	padding-left: 5px;
}</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/08/detect-browser-in-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Sleep or Wait function</title>
		<link>http://tech.avivo.si/2010/07/javascript-sleep-of-wait-function/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-sleep-of-wait-function</link>
		<comments>http://tech.avivo.si/2010/07/javascript-sleep-of-wait-function/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 22:44:14 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sleep function]]></category>
		<category><![CDATA[thread.sleep in javascript]]></category>
		<category><![CDATA[wait function]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=553</guid>
		<description><![CDATA[This can be one possible implementation (not very clean, but working): function sleep(numberMillis){ var now = new Date(); var exitTime = now.getTime() + numberMillis; while (true){ now = new Date(); if (now.getTime() > exitTime) return; } };]]></description>
			<content:encoded><![CDATA[<p>This can be one possible implementation (not very clean, but working):</p>
<pre lang="javascript">
function sleep(numberMillis){
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true){
		now = new Date();
		if (now.getTime() > exitTime) return;
	}
};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/07/javascript-sleep-of-wait-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Submit query text in Image Button?</title>
		<link>http://tech.avivo.si/2010/04/submit-query-text-in-image-button/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=submit-query-text-in-image-button</link>
		<comments>http://tech.avivo.si/2010/04/submit-query-text-in-image-button/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 16:55:23 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[image button]]></category>
		<category><![CDATA[strange text in my button]]></category>
		<category><![CDATA[Submit query text]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=482</guid>
		<description><![CDATA[You got this message in your browser while using image as button. Just replace your code with this (value attribute is crucial): &#60;input name="search" type="submit" /&#62; to &#60;input name="search" type="submit" value="Search" /&#62;]]></description>
			<content:encoded><![CDATA[<p>You got this message in your browser while using image as button.</p>
<p>Just replace your code with this (<strong>value </strong>attribute is crucial):</p>
<pre class="php">&lt;input name="search" type="submit" /&gt;

to

&lt;input name="search" type="submit" value="Search" /&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/04/submit-query-text-in-image-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prevent link click with JQuery, avoid the javascript:void(0)</title>
		<link>http://tech.avivo.si/2010/03/prevent-link-click-with-jquery-avoid-the-javascriptvoid0/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prevent-link-click-with-jquery-avoid-the-javascriptvoid0</link>
		<comments>http://tech.avivo.si/2010/03/prevent-link-click-with-jquery-avoid-the-javascriptvoid0/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 12:52:19 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[avoid link click]]></category>
		<category><![CDATA[avoid the void]]></category>
		<category><![CDATA[do not use javascript:void(0)]]></category>
		<category><![CDATA[how to prevent a href click]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prevent javascript:void(0)]]></category>
		<category><![CDATA[prevent link click using jquery]]></category>
		<category><![CDATA[search engine optimization]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=456</guid>
		<description><![CDATA[It is forbidden to use: &#60;a href="javascript:void(0);"&#62;Some text&#60;/a&#62; Instead of that use JQuery to simulate link and you can put in href attribute whatever you want: &#60;a id="myLink" href="everything-i-want-to-rewrite" title="link title"&#62;Some text&#60;/a&#62; And in JQuery use this: $("#myLink").click(function(e) { // //do something // //Prevent event propagation and click e.preventDefault(); });]]></description>
			<content:encoded><![CDATA[<div style="margin-bottom:30px;">
It is forbidden to use:</p>
<pre class="html">
&lt;a href="javascript:void(0);"&gt;Some text&lt;/a&gt;
</pre>
</div>
<div style="margin-bottom:30px;">
Instead of that use JQuery to simulate link and you can put in href attribute whatever you want:</p>
<pre class="html">
&lt;a id="myLink" href="everything-i-want-to-rewrite" title="link title"&gt;Some text&lt;/a&gt;
</pre>
</div>
<p>And in JQuery use this:</p>
<pre class="javascript">
$("#myLink").click(function(e) {
  //
  //do something
  //

  //Prevent event propagation and click
  e.preventDefault();
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/03/prevent-link-click-with-jquery-avoid-the-javascriptvoid0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to center div using JQuery</title>
		<link>http://tech.avivo.si/2010/01/how-to-center-div-using-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-center-div-using-jquery</link>
		<comments>http://tech.avivo.si/2010/01/how-to-center-div-using-jquery/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 17:55:53 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[align center]]></category>
		<category><![CDATA[calculate div position]]></category>
		<category><![CDATA[calculate element position]]></category>
		<category><![CDATA[center div  inside another div]]></category>
		<category><![CDATA[center div using javascript]]></category>
		<category><![CDATA[center element in html]]></category>
		<category><![CDATA[find left offset]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[offset]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=299</guid>
		<description><![CDATA[How can you center div or how can you center div inside another div? This is a common problem. For example, you have a paging with different number of pages and you need to center whole paging div inside parent div container. JQuery is helpful there. Look first at the picture (we want to center [...]]]></description>
			<content:encoded><![CDATA[<p>How can you center <strong>div </strong>or how can you center div inside another <strong>div</strong>?</p>
<p>This is a common problem.</p>
<p>For example, you have a paging with different number of pages and you need to center whole paging <strong>div </strong>inside parent div container.</p>
<p><strong>JQuery </strong>is helpful there.</p>
<p>Look first at the picture (we want to center this paging control inside parent <strong>div </strong>control)</p>
<div id="attachment_306" class="wp-caption alignnone" style="width: 694px"><a href="http://tech.avivo.si/wp-content/uploads/2010/01/paging.jpg"><img class="size-full wp-image-306" title="Center paging control" src="http://tech.avivo.si/wp-content/uploads/2010/01/paging.jpg" alt="Center paging control" width="684" height="72" /></a><p class="wp-caption-text">Center paging control</p></div>
<div style="margin-top:30px;">If you have paging <strong>div</strong>:</div>
<pre class="html">&lt;div id="paging" class="jPaginate" style="padding-left: 67px; left: 0px;"&gt;
  &lt;div class="jPag-control-back"&gt;&lt;a class="jPag-first" style="border: 1px solid #8496ad;
    color: #000000; background-color: #ffffff;"&gt;First&lt;/a&gt;
    &lt;span class="jPag-sprevious"&gt;«&lt;/span&gt;&lt;/div&gt;
  &lt;div style="overflow: hidden; width: 410px;"&gt;
    &lt;ul class="jPag-pages"&gt;
      &lt;li&gt;&lt;span class="jPag-current" style="border: 1px solid #cccccc; color: #ffffff;
        background-color: #0075ff;"&gt;1&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a style="border: 1px solid #8496ad; color: #000000;
        background-color: #ffffff;"&gt;2&lt;/a&gt;&lt;/li&gt;
      &lt;!--...more pages...--&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div class="jPag-control-front" style="left: 481px;"&gt;
     &lt;span class="jPag-snext"&gt;»&lt;/span&gt;&lt;a class="jPag-last"
     style="border: 1px solid #8496ad; color: #000000;
     background-color: #ffffff;"&gt;Last&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;</pre>
<div style="margin-top:30px;">You can use JQuery syntax:</div>
<pre class="js">$("#paging").css('left',($("#paging").width() -
  ($(".jPag-control-front").position().left +
   $(".jPag-control-front").width())) / 2);</pre>
<div style="margin-top:30px;">What does this JQuery command do?</div>
<ul>
<li>$(&#8220;#paging&#8221;) &#8211; finds <strong>div </strong>with<strong> id=&#8221;paging&#8221;</strong></li>
<li>$(&#8220;#paging&#8221;).css(&#8216;left&#8217;, 50); &#8211; move left <strong>&#8220;paging&#8221; </strong><strong>div </strong>for 50px</li>
<li>$(&#8220;.jPag-control-front&#8221;).position().left &#8211; finds left distance for <strong>div </strong>element that has css <strong>class=&#8221;jPag-control-front&#8221; </strong>from the beginning of <strong>&#8220;paging&#8221; div </strong></li>
<li>So, you get the left distance of <strong>Last element </strong>(<strong>div </strong>that has css <strong>class=&#8221;jPag-control-front&#8221; </strong>) and you add the width of <strong>Last </strong>element to this left offset and then you substract this sum from parent <strong>div </strong>width and, at the end, you divide all this by two to get the blank space you need to move you paging <strong>div </strong>from the left.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/01/how-to-center-div-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Best CSS Practices to Improve Your Code</title>
		<link>http://tech.avivo.si/2009/12/10-best-css-practices-to-improve-your-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=10-best-css-practices-to-improve-your-code</link>
		<comments>http://tech.avivo.si/2009/12/10-best-css-practices-to-improve-your-code/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 23:21:39 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[10 Best CSS Practices to Improve Your Code]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=228</guid>
		<description><![CDATA[We found these guides here at WebDesignerDepot.com: 1. Stay Organized Just like anything else, it pays to keep yourself organized. Rather than haphazardly dropping in id’s and classes in the order in which they come to mind, use a coherent structure. It will help you keep the cascading part of CSS in mind and sets [...]]]></description>
			<content:encoded><![CDATA[<p>We found these guides <a href="http://www.webdesignerdepot.com/2009/05/10-best-css-practices-to-improve-your-code/" target="_blank">here at WebDesignerDepot.com</a>:</p>
<h2>1. Stay Organized</h2>
<p>Just like anything else, it pays to keep yourself organized. Rather than haphazardly dropping in id’s and classes in the order in which they come to mind, use a coherent structure.</p>
<p>It will help you keep the cascading part of CSS in mind and sets your style sheet up to take advantage of style inheritance.</p>
<p><strong>Declare your most generic items first, then the not-so-generic and so on.</strong> This lets your CSS properly inherit attributes and makes it much easier for you to override a specific style when you need to. You’ll be faster at editing your CSS later because it will follow an easy to read, logical structure.</p>
<p>Use a structure that works best for you while keeping future edits and other developers in mind.</p>
<ul>
<li><strong>Resets and overrides</strong></li>
<li><strong>Links and type</strong></li>
<li><strong>Main layout</strong></li>
<li><strong>Secondary layout structures</strong></li>
<li><strong>Form elements</strong></li>
<li><strong>Miscellaneous</strong></li>
</ul>
<p><img src="http://netdna.webdesignerdepot.com/uploads/best_css_practices/best-css-02.jpg" alt="Screenshot" /></p>
<h2>2. Title, Date and Sign</h2>
<p>Let others know who wrote your CSS, when it was written and who to contact if they have questions about it. This is especially useful when designing templates or themes.</p>
<p><img src="http://netdna.webdesignerdepot.com/uploads/best_css_practices/best-css-03.jpg" alt="Screenshot" /></p>
<p>Wait a minute… what’s that bit about <strong>swatch colors</strong>? Over the years, I’ve found that adding a simple list of common colors used in my style sheets is extremely helpful during initial development and when making edits later on.</p>
<p>This saves you from having to open up Photoshop to sample a color from the design, or look up colors in the site’s <a rel="nofollow" href="http://en.wikipedia.org/wiki/Style_guide">style guide</a> (if it has one). When you need the HTML code for that specific blue, just scroll up and copy it.</p>
<h2>3. Keep a Template Library</h2>
<p>Once you’ve settled on a structure to use, strip out everything that isn’t generic and save the file as a CSS template for later use.</p>
<p>You can save multiple versions for multiple uses: a two-column layout, a blog layout, print, mobile and so on. <a rel="nofollow" href="http://www.panic.com/coda/">Coda</a> (the editor for OSX) has an awesome <strong>Clips</strong> feature that lets you do this easily. Many other editors have a similar feature, but even a simple batch of text files will work nicely.</p>
<p>It’s insane to re-write each and every one of your style sheets from scratch, especially when you’re using the same conventions and methodologies in each.</p>
<p><a rel="nofollow" href="http://www.flickr.com/photos/misterdna/49841409/"><img src="http://netdna.webdesignerdepot.com/uploads/best_css_practices/best-css-04.jpg" alt="Screenshot" /></a></p>
<h2>4. Use Useful Naming Conventions</h2>
<p>You’ll notice above where I declared a couple of column id’s and I called them col-alpha and col-beta. Why not just call them col-left and col-right? Think of future edits, always.</p>
<p>Next year you may need to redesign your site and move that left column to the right. You shouldn’t have to rename the element in your HTML and rename the id in your style sheet just to change its position.</p>
<p>Sure, you could just reposition that left column to the right and keep the id as #col-left, but how confusing is that? If the id says left, one should expect that it will always be on the left. This doesn’t leave you much room to move things around later on.</p>
<p>One of the major advantages of CSS is the ability to separate styles from content. You can totally redesign your site by just modifying the CSS without ever touching the HTML. So <strong>don’t muck up your CSS by using limiting names</strong>. Use more versatile naming conventions and stay consistent.</p>
<p>Leave position or style specific words out of your styles and id’s. A class of .link-blue will either make more work for you, or make your style sheet really messy when your client later asks you to change those blue links to orange.</p>
<p><strong>Name your elements based on what they are, not what they look like.</strong> For example, .comment-blue is much less versatile than .comment-beta, and .post-largefont is more limiting than .post-title.</p>
<h2>5. Hyphens Instead of Underscores</h2>
<p>Older browsers like to get glitchy with underscores in CSS, or don’t support them at all. For better backward compatibility, get into the habit of using hyphens instead. Use #col-alpha rather than #col_alpha.</p>
<h2>6. Don’t Repeat Yourself</h2>
<p>Re-use attributes whenever possible by grouping elements instead of declaring the styles again. If your h1 and h2 elements both use the same font size, color and margins, group them using a comma.</p>
<p>This:</p>
<p><img src="http://netdna.webdesignerdepot.com/uploads/best_css_practices/best-css-05.jpg" alt="Screenshot" /></p>
<p>You should also make use of shortcuts whenever possible. Always be on the lookout for opportunities to group elements and use declaration shortcuts.</p>
<p>You can accomplish all of this:</p>
<p><img src="http://netdna.webdesignerdepot.com/uploads/best_css_practices/best-css-06.jpg" alt="Screenshot" /></p>
<p>with only this:</p>
<p><img src="http://netdna.webdesignerdepot.com/uploads/best_css_practices/best-css-07.jpg" alt="Screenshot" /></p>
<p>It’s very important that you understand the order in which CSS interprets these shortcuts: top, right, bottom, left. A big clockwise circle, starting at noon.</p>
<p>Also, if your top and bottom, or left and right attributes are the same, you only need to use two:</p>
<p><img src="http://netdna.webdesignerdepot.com/uploads/best_css_practices/best-css-08.jpg" alt="Screenshot" /></p>
<p>This sets the top and bottom margins to 1em, and the left and right margins to 0.</p>
<h2>7. Optimize for Lightweight Style Sheets</h2>
<p>Using the above tips, you can really cut down the size of your style sheets. Smaller loads faster, and smaller is easier to maintain and update.</p>
<p>Cut out what you don’t need and consolidate wherever possible by grouping. Use caution when using canned CSS frameworks as well. You’re likely to inherit lots of bulk that won’t be used.</p>
<p>Another quick tip for slim CSS: you don’t need to specify a unit of measure when using zero. If a margin is set to 0, you don’t need to say 0px or 0em. Zero is zero regardless of the unit of measure, and CSS understands this.</p>
<h2>8. Write Your Base for Gecko, Then Tweak for Webkit and IE</h2>
<p>Save yourself troubleshooting headaches and write CSS first for Gecko browsers (Firefox, Mozilla, Netscape, Flock, Camino). If your CSS works properly with Gecko, it’s much more likely to be problem free in Webkit (Safari, Chrome) and Internet Explorer.</p>
<h2>9. Validate</h2>
<p>Make use of <a rel="nofollow" href="http://jigsaw.w3.org/css-validator/">W3C’s free CSS validator</a>. If you’re stuck and your layout isn’t doing what you want it to do, the CSS validator will be a big help in pointing out errors.</p>
<h2>10. Keep a tidy house</h2>
<p>Separate browser-specific CSS to its own individual style sheet, and include as needed with Javascript, server-side code or <a rel="nofollow" href="http://en.wikipedia.org/wiki/Conditional_comments">conditional comments</a>. Use this method to avoid dirty CSS hacks in your main style sheets. This will keep your base CSS clean and manageable.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/12/10-best-css-practices-to-improve-your-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

