<?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>Uzza &#187; Css</title>
	<atom:link href="http://uzza.pl/blog/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://uzza.pl/blog</link>
	<description>Just my online notepad</description>
	<lastBuildDate>Wed, 01 Feb 2012 10:57:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Dealing with IE bugs if you keep all styles in one file</title>
		<link>http://uzza.pl/blog/2011/08/15/dealing-with-ie7-bugs-if-you-keep-all-styles-in-one-file/</link>
		<comments>http://uzza.pl/blog/2011/08/15/dealing-with-ie7-bugs-if-you-keep-all-styles-in-one-file/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 12:12:57 +0000</pubDate>
		<dc:creator>Łukasz Lipiński</dc:creator>
				<category><![CDATA[Compatibility]]></category>
		<category><![CDATA[Css]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[ie7]]></category>

		<guid isPermaLink="false">http://uzza.pl/blog/?p=187</guid>
		<description><![CDATA[IE6: * html .input &#123; margin-top:1px; &#125; IE7: *:first-child+html .input_box &#123; margin-top:1px; &#125; IE8: @media \0screen { .color &#123;color: #F00;&#125; &#125;]]></description>
			<content:encoded><![CDATA[<p>IE6:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> html <span style="color: #6666ff;">.input</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>IE7:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span><span style="color: #3333ff;">:first-child</span><span style="color: #00AA00;">+</span>html <span style="color: #6666ff;">.input_box</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>IE8:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media \0screen {</span>
  .<span style="color: #000000; font-weight: bold;">color</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F00</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://uzza.pl/blog/2011/08/15/dealing-with-ie7-bugs-if-you-keep-all-styles-in-one-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modernizr</title>
		<link>http://uzza.pl/blog/2011/07/07/modernizr/</link>
		<comments>http://uzza.pl/blog/2011/07/07/modernizr/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 21:09:26 +0000</pubDate>
		<dc:creator>Łukasz Lipiński</dc:creator>
				<category><![CDATA[Css]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://uzza.pl/blog/?p=48</guid>
		<description><![CDATA[Use it if you need to detect browser features or add conditional script loading. http://www.modernizr.com/]]></description>
			<content:encoded><![CDATA[<p>Use it if you need to detect browser features or add conditional script loading.<br />
<a href="http://www.modernizr.com/" title="http://www.modernizr.com/" target="_blank">http://www.modernizr.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uzza.pl/blog/2011/07/07/modernizr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gradient Scanner</title>
		<link>http://uzza.pl/blog/2011/07/07/gradient-scanner/</link>
		<comments>http://uzza.pl/blog/2011/07/07/gradient-scanner/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 20:34:19 +0000</pubDate>
		<dc:creator>Łukasz Lipiński</dc:creator>
				<category><![CDATA[Css]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://uzza.pl/blog/?p=43</guid>
		<description><![CDATA[This is a website-tool that analyzes the image file searching gradients and creates css rule for it. http://gradient-scanner.com/]]></description>
			<content:encoded><![CDATA[<p>This is a website-tool that analyzes the image file searching gradients and creates css rule for it.<br />
<a href="http://gradient-scanner.com/" title="http://gradient-scanner.com/" target="_blank">http://gradient-scanner.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uzza.pl/blog/2011/07/07/gradient-scanner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drag &amp; Drop in few lines of code</title>
		<link>http://uzza.pl/blog/2011/07/06/5/</link>
		<comments>http://uzza.pl/blog/2011/07/06/5/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 20:29:44 +0000</pubDate>
		<dc:creator>Łukasz Lipiński</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Css]]></category>
		<category><![CDATA[drga&drop]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://uzza.megiteam.pl/blog/?p=5</guid>
		<description><![CDATA[Implementing possiblity of moving elements on website seems to be hard for person with little experience with Javascript. Only thought is &#8220;i need to use some library&#8221;, it&#8217;s realy good]]></description>
			<content:encoded><![CDATA[<p>Implementing possiblity of moving elements on website seems to be hard for person with little experience with Javascript. Only thought is &#8220;i need to use some library&#8221;, it&#8217;s realy good idea&#8230; ? when we want add only one feature ? Probably not&#8230; I&#8217;ll show You 30 lines of code which does it.  </p>
<p><a href="http://www.uzza.pl/blog/files/development/javascript/drag_and_drop/files.zip">Download files</a></p>
<p><a href="http://www.uzza.pl/blog/files/development/javascript/drag_and_drop/" target="_blank">View Example</a></p>
<p>Please open Your favourite text editor or other tool which You are using to write Your code and type:</p>
<p><b>Primary content of HTML file</b></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;pl&quot;</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;pl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Drag <span style="color: #ddbb00;">&amp;amp;</span> Drop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Between of BODY tags add DIV element (with its drag indicator) which will be moved.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;drag_indicator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>In next order we are connecting style sheet and javascript file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;dragdrop.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Body of .css file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">div.drag_indicator {
    width            : 100px;
    height           : 20px;
    background-color : yellow;
}
&nbsp;
#block1 {
    width            : 100px;
    height           : 100px;
    background-color : red;
    position         : absolute;
}</pre></div></div>

<p>In this way we defined red block of 100&#215;100 pixels dimension with absolute position relative to browser window and yellow block of 100&#215;20 pixels dimension.</p>
<p>In file with .js extension we are writing code which catch 3 actions in document object:</p>
<ul>
<li>onmousedown &#8211; when user press mouse button</li>
<li>onmousemove &#8211; when user move mouse cursor</li>
<li>onmouseup &#8211; when user release mouse button</li>
</ul>
<p>Please look, mouse movement will be supported only when mouse button is pressed, that&#8217;s why <b>onmousemove</b> event is captured in <b>onmousedown</b> event.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">document.onmousedown = function(e) {
    e = (e || event);
&nbsp;
    document.onmousemove = function(e) {
        e = (e || event);          
    }
};
&nbsp;
document.onmouseup = function(e) {
};</pre></div></div>

<p>Code which supports events in Internet Explorer browser</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">e = (e || event);</pre></div></div>

<p>When mouse button is pressed &#8220;onmousedown&#8221; event is activated. In first order we catch clicked object:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">var target = e.target || e.srcElement;</pre></div></div>

<p>If it is a HTML element, we break a code because this is highest embed element.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">if (target.tagName == 'HTML')
        return;</pre></div></div>

<p>In next step, we are looking for &#8220;drag_indicator&#8221; class in clicked element. If it haven&#8217;t, we are checking its parent nodes as long as we&#8217;ll found it or we came to the top of elements tree.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">while (target != document.body <span style="color: #ddbb00;">&amp;&amp; (target.className || &quot;&quot;).indexOf(&quot;drag_indicator&quot;) == -1) {</span>
<span style="color: #ddbb00;">    target = target.parentNode || target.parentElement;</span>
}</pre></div></div>

<p>If correct element haven&#8217;t been found, we break a script</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">if ((target.className || &quot;&quot;).indexOf(&quot;drag_indicator&quot;) == -1)
        return;</pre></div></div>

<p>When correct element has been clicked (div with block_indicator css class) script will go further. Because we wants to move entire block, not only a indicator we needs to find out its object. <b>block_indicator</b> is a child of block, so we needs to get it as follow:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">target = target.parentNode;</pre></div></div>

<p>In nexts lines we credit cursor position at the moment of click to <b>sx</b> and <b>sy</b> variables.  In <b>dx</b> and <b>dy</b> we&#8217;ll keeping alteration (default is 0) and in <b>l</b> and <b>t</b> current position of block element.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"> var sx = e.clientX, sy = e.clientY,
      dx = 0, dy = 0,
      l = target.offsetLeft,
      t = target.offsetTop;</pre></div></div>

<p>In Firefox browser we encount a inconvenience of moving block. We can solve this problem using that condition:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">if (e.preventDefault) {
    e.preventDefault();
}</pre></div></div>

<p>In this moment we have all initial values. Now time has come for implementing dragging.</p>
<p>When block is moving, this function is called</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">document.onmousemove = function(e) {
}</pre></div></div>

<p>To change a block position we need to read mouse cursor current position (e.clientX, e.clientY) and subtract it from initial values simultaneously saving it to <b>dx</b> i <b>dy</b>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">dx = e.clientX - sx;
dy = e.clientY - sy;</pre></div></div>

<p>Finaly, we need to set current position (last position + alteration) to block element.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">target.style.left = (l + dx) + &quot;px&quot;;
target.style.top  = (t + dy) + &quot;px&quot;;</pre></div></div>

<p>When mouse button will be release, following code will be ran:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">document.onmouseup = function(e) {
    document.onmousemove = null;
};</pre></div></div>

<p>In this way, we created cross-browser compatible code that is smaller than 1kB.</p>
]]></content:encoded>
			<wfw:commentRss>http://uzza.pl/blog/2011/07/06/5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

