<?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>Vacheslav Starikov&#039;s &#187; css</title>
	<atom:link href="http://starikovs.com/cat/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://starikovs.com</link>
	<description>BLOG</description>
	<lastBuildDate>Sun, 05 Sep 2010 18:05:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using CSS3 rounded corners in practice</title>
		<link>http://starikovs.com/2010/08/24/css3-rounded-corners/</link>
		<comments>http://starikovs.com/2010/08/24/css3-rounded-corners/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 08:44:38 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=224</guid>
		<description><![CDATA[
	div.css3-rounded-corners {
		width: 100px;
		height: 50px;
		border: 2px solid #000;
		background-color: #fff;
	}
	#border-radius {
		border-color: red;
		border-radius: 20px; /* CSS3 declaration */
		-webkit-border-radius: 20px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius: 20px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-radius: 20px; /* Linux browsers */
		behavior: url(/my-examples/files/border-radius.htc); /* maybe ALL IE */
	}
	#border-top-right-radius {
		border-color: green;
		border-top-right-radius: 20px; /* CSS3 declaration */
		-webkit-border-top-right-radius: 20px; /* declaration [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
	div.css3-rounded-corners {
		width: 100px;
		height: 50px;
		border: 2px solid #000;
		background-color: #fff;
	}
	#border-radius {
		border-color: red;
		border-radius: 20px; /* CSS3 declaration */</p>
<p>		-webkit-border-radius: 20px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius: 20px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-radius: 20px; /* Linux browsers */
		behavior: url(/my-examples/files/border-radius.htc); /* maybe ALL IE */
	}
	#border-top-right-radius {
		border-color: green;
		border-top-right-radius: 20px; /* CSS3 declaration */</p>
<p>		-webkit-border-top-right-radius: 20px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius-topright: 20px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-top-right-radius: 20px; /* Linux browsers */
	}
	#border-bottom-right-radius {
		border-color: blue;
		border-bottom-right-radius: 20px; /* CSS3 declaration */</p>
<p>		-webkit-border-bottom-right-radius: 20px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius-bottomright: 20px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-bottom-right-radius: 20px; /* Linux browsers */
	}
	#border-bottom-left-radius {
		border-color: orange;
		border-bottom-left-radius: 20px; /* CSS3 declaration */</p>
<p>		-webkit-border-bottom-left-radius: 20px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius-bottomleft: 20px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-bottom-left-radius: 20px; /* Linux browsers */
	}
	#border-top-left-radius {
		border-color: pink;
		border-top-left-radius: 20px; /* CSS3 declaration */</p>
<p>		-webkit-border-top-left-radius: 20px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius-topleft: 20px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-top-left-radius: 20px; /* Linux browsers */
	}
	#border-complex1-radius {
		border-color: Gold;</p>
<p>		border-radius: 30px 0 30px 0; /* CSS3 declaration */</p>
<p>		-webkit-border-radius: 30px 0 30px 0; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius: 30px 0 30px 0; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-radius: 30px 0 30px 0; /* Linux browsers */
	}
	#border-complex2-radius {
		border-color: OrangeRed;</p>
<p>		border-radius: 10px 30px 10px 30px ; /* CSS3 declaration */</p>
<p>		-webkit-border-radius: 10px 30px 10px 30px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius: 10px 30px 10px 30px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-radius: 10px 30px 10px 30px; /* Linux browsers */
	}
	#border-complex3-radius {
		border-color: violet;</p>
<p>		border-radius: 20px 20px 5px 5px / 40px 40px 5px 5px; /* CSS3 declaration */</p>
<p>		-webkit-border-radius: 20px 20px 5px 5px / 40px 40px 5px 5px; /* declaration for WebKit browsers like: Safari, Chrome */
		-moz-border-radius: 20px 20px 5px 5px / 40px 40px 5px 5px; /* declaration for Mozilla browsers like FireFox */
		-khtml-border-radius: 20px 20px 5px 5px / 40px 40px 5px 5px; /* Linux browsers */
	}
        table.css3-rounded-corners-table td { border: 0; padding: 7px; vertical-align: middle; }
</style>
<p>In this article, I am going to test CSS 3 rounded corners. I do want to know can if I can use them in practice in different browsers. Here are some examples of CSS3 rounded corners and if you can see some rounded corners &#8211; congratulations your browser supports them!</p>
<table border="0" class="css3-rounded-corners-table">
<tr>
<td>
<div id="border-radius" class="css3-rounded-corners"></div>
</td>
<td>border-radius: 20px</td>
</tr>
<tr>
<td>
<div id="border-top-right-radius" class="css3-rounded-corners"></div>
</td>
<td>border-top-right-radius: 20px</td>
</tr>
<tr>
<td>
<div id="border-bottom-right-radius" class="css3-rounded-corners"></div>
</td>
<td>border-bottom-right-radius: 20px</td>
</tr>
<tr>
<td>
<div id="border-bottom-left-radius" class="css3-rounded-corners"></div>
</td>
<td>border-bottom-left-radius: 20px</td>
</tr>
<tr>
<td>
<div id="border-top-left-radius" class="css3-rounded-corners"></div>
</td>
<td>border-top-left-radius: 20px</td>
</tr>
<tr>
<td>
<div id="border-complex1-radius" class="css3-rounded-corners"></div>
</td>
<td>border-radius: 30px 0 30px 0</td>
</tr>
<tr>
<td>
<div id="border-complex2-radius" class="css3-rounded-corners"></div>
</td>
<td>border-radius: 10px 30px 10px 30px</td>
</tr>
<tr>
<td>
<div id="border-complex3-radius" class="css3-rounded-corners"></div>
</td>
<td>border-radius: 20px 20px 5px 5px / 40px 40px 5px 5px</td>
</tr>
</table>
<p><span id="more-224"></span></p>
<h3>Browsers</h3>
<p>Before CSS3 appeared, web developers had to use some combinations of DIV’s or other container elements with curved corner images to achieve the desired result. Today, when CSS3 is supported by almost all the popular browsers the approach to make rounded corners is very easier, shorter and faster.</p>
<p>The only one little problem has place, is the compatibility with IE.</p>
<p>Here’s the table of browsers I tested on:</p>
<table>
<tr>
<th>Browser</th>
<th>Supports rounded corners</th>
</tr>
<tr>
<td>FireFox 3.6</td>
<td>Yes</td>
</tr>
<tr>
<td>Safari 5</td>
<td>Yes</td>
</tr>
<tr>
<td>Opera 10</td>
<td>Yes</td>
</tr>
<tr>
<td>Chrome</td>
<td>Yes</td>
</tr>
<tr>
<td>IE 6+</td>
<td>Limited and only with hacks</td>
</tr>
<tr>
<td>IE 9</td>
<td>Microsoft pomised</td>
</tr>
</table>
<h3>IE workaround</h3>
<p>To make curved corners in IE the behavior htc file should be used. You can download the file from here <a href="http://code.google.com/p/curved-corner/" target="_blank">http://code.google.com/p/curved-corner/</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* CSS3 declaration */</span>
...
behavior<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">border-radius.htc</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>There&#8217;re some limitations, for example, this behaviour htc file can round only all the corners of the container, but it cannot round only one, two or three specific corners. So, the CSS3 allows to round only right corner, for example, but the behavior htc file doesn’t. Other issues you can find at the page of this htc file.</p>
<h3>CSS rules for all browsers</h3>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* CSS3 declaration */</span>
border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> 
&nbsp;
<span style="color: #808080; font-style: italic;">/* declaration for WebKit browsers like: Safari, Chrome */</span>
-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> 
&nbsp;
<span style="color: #808080; font-style: italic;">/* declaration for Mozilla browsers like FireFox */</span>
-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> 
&nbsp;
 <span style="color: #808080; font-style: italic;">/* Linux browsers */</span>
-khtml-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
&nbsp;
 <span style="color: #808080; font-style: italic;">/* maybe ALL IE */</span>
behavior<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">border-radius.htc</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></div></div>

<h3>Understanding syntax</h3>
<p>The curved corner is a quarter of the ellipse that defines the shape of the corner. To understand that see the image from the W3C:</p>
<p><img src="http://www.w3.org/TR/2002/WD-css3-border-20021107/corner.png" alt="Ellipse that defines the shape of the corners." /></p>
<p>So, to define the rounded corner the horizontal and vertical radii should be set, but the vertical radius parameter is optional. If you define only one parameter it will be applied to the horizontal and vertical radii.</p>
<p>Now, let’s see the syntax:</p>
<p><strong>border-radius:</strong> <span style="color:#D2691E">[&lt;length&gt; | &lt;percentage&gt;]{1,4}</span><span style="color:#228B22"> [ / [&lt;length&gt; | &lt;percentage&gt;]{1,4} ]?</span></p>
<p><span style="color:#D2691E">The first parameter defines the horizontal radius and if the second parameter is missed the vertical radius.</span></p>
<p><span style="color:#228B22">The second parameter defines the vertical radius of the ellipse that defines the shape of the corner.</span></p>
<p>The ‘border-radius’ sets values for all the four corners.</p>
<p><strong>Examples:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* all the corners have an equal curved corner */</span>
border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> 
&nbsp;
 <span style="color: #808080; font-style: italic;">/* works as in the picture above */</span>
border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">55pt</span> / <span style="color: #933;">25pt</span><span style="color: #00AA00;">;</span></pre></div></div>

<p><strong>border-top-right-radius, <br />border-bottom-right-radius, <br />border-bottom-left-radius, <br />border-top-left-radius: </strong><span style="color:#D2691E">[&lt;length&gt; | &lt;percentage&gt;]</span><span style="color:#228B22"> [&lt;length&gt; | &lt;percentage&gt;]?</span></p>
<p><span style="color:#D2691E">The first parameter defines the horizontal radius and if the second parameter is missed the vertical radius.</span></p>
<p><span style="color:#228B22">The second parameter defines the vertical radius of the ellipse that defines the shape of the corner.</span></p>
<p>All of these properties set the only one specific corner.</p>
<p><strong>Examples:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* sets the top left corner */</span>
border-top-left-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
&nbsp;
 <span style="color: #808080; font-style: italic;">/* sets the top right corner as in the picture above */</span>
border-top-right-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">55pt</span> <span style="color: #933;">25pt</span><span style="color: #00AA00;">;</span></pre></div></div>

<p><strong>More info on syntax you can find at W3C site:</strong> <a href="http://www.w3.org/TR/2010/WD-css3-background-20100612/#the-border-radius" target="_blank">http://www.w3.org/TR/2010/WD-css3-background-20100612/#the-border-radius</a>.</p>
<h3>Practice</h3>
<p>Let&#8217;s create a div the corners of which we will curve.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;curved-corners&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>To curve all the corners we should write these styles:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#curved-corners</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/* CSS3 declaration */</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> 
&nbsp;
        <span style="color: #808080; font-style: italic;">/* declaration for WebKit browsers like: Safari, Chrome */</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> 
&nbsp;
        <span style="color: #808080; font-style: italic;">/* declaration for Mozilla browsers like FireFox */</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> 
&nbsp;
        <span style="color: #808080; font-style: italic;">/* Linux browsers */</span>
	-khtml-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/* maybe ALL IE  */</span>
	behavior<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">border-radius.htc</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>By the way, you should download border-radius.htc from Google Code and copy it to the location you need, and then specify the correct path to border-radius.htc. So, let&#8217;s look at the example above in work:</p>
<div style="position:relative;width:100px;height:50px;border:2px solid red;border-radius:20px;-webkit-border-radius:20px;-moz-border-radius:20px;-khtml-border-radius: 20px;behavior:url(/my-examples/files/border-radius.htc);background-color:#fff;"></div>
<p>Now, let&#8217;s curve only top left and bottom right borders. We are still using the same DIV but define another styles.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#curved-corners</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/* CSS3 declaration */</span>
	border-top-left-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> 
	border-bottom-right-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> 
&nbsp;
        <span style="color: #808080; font-style: italic;">/* declaration for WebKit browsers like: Safari, Chrome */</span>
	-webkit-border-top-left-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> 
	-webkit-border-bottom-right-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> 
&nbsp;
        <span style="color: #808080; font-style: italic;">/* declaration for Mozilla browsers like FireFox */</span>
	-moz-border-radius-topleft<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius-bottomright<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/* Linux browsers */</span>
	-khtml-border-top-left-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	-khtml-border-bottom-right-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>We aren&#8217;t using htc file for IE because it cannot curve specific corners. It can curve all the four corners only. So, let&#8217;s see the example above at work:</p>
<div style="width:100px;height:50px;border:2px solid blue;border-top-left-radius:20px;border-bottom-right-radius: 20px;-webkit-border-top-left-radius:20px;-webkit-border-bottom-right-radius:20px;-moz-border-radius-topleft:20px;-moz-border-radius-bottomright:20px;-khtml-border-top-left-radius:20px;-khtml-border-bottom-right-radius:20px;"></div>
<h3>Conclusion</h3>
<p>After testing how CSS3 can round borders, I can say that it&#8217;s cool. Even if you want to curve borders in IE6+ there&#8217;s a workaround but it&#8217;s a bit limited. I hope that some issues for this IE htc file will be fixed soon. Microsoft promised that IE9 will support CCS3 technique to curve corners. By the way, there&#8217;re a lot of popular web sites that have already begun to use CSS3 technique to round corners.</p>
<h3>Links</h3>
<p><a href="http://www.w3.org/TR/2002/WD-css3-border-20021107/#the-border-radius" target="_blank">W3C CSS3 Border Radius</a></p>
<p><a href="http://www.w3.org/TR/2010/WD-css3-background-20100612/#the-border-radius" target="_blank">W3C CSS3 Border Radius newer doc</a></p>
<p><a href="http://code.google.com/p/curved-corner/" target="_blank">Rounded corner HTML elements using CSS3 in IE (Download at Google Code)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2010/08/24/css3-rounded-corners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Centering horizontal CSS menu</title>
		<link>http://starikovs.com/2009/12/04/centering-horizontal-css-menu/</link>
		<comments>http://starikovs.com/2009/12/04/centering-horizontal-css-menu/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 17:00:16 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[codecharge]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=176</guid>
		<description><![CDATA[It&#8217;s a real headache to center a fluid block element horizontally with help of CSS. Some time ago I figured out how to center CodeCharge Studio&#8217;s CSS Menu because it doesn&#8217;t provide this functionality. In general, any block element without the fixed width can be centered with help of this method. 
By the way, if [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a real headache to center a fluid block element horizontally with help of CSS. Some time ago I figured out how to center CodeCharge Studio&#8217;s CSS Menu because it doesn&#8217;t provide this functionality. In general, any block element without the fixed width can be centered with help of this method. </p>
<p>By the way, if You have a fixed width block then You have to set its left and right margins to auto and You get the block centered. </p>
<p>In this article I&#8217;m going to explain the method I use to center a fluid block element. Here is the <a href="http://starikovs.com/my-examples/centering-horizontal-css-menu/test.php" target="_blank">Demo</a>.</p>
<p><span id="more-176"></span></p>
<p>With help of this method You can center:</p>
<ul>
<li>CodeCharge Studio&#8217;s Menu (CCS Menu)</li>
<li>Horizontal CSS Menu</li>
<li>Any block elements (DIV, SPAN, IMG, UL, etc.)</li>
</ul>
<h3>HTML</h3>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- BEGIN Menu Menu1 --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;MenuStyle&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Menu1Container&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;adxm {Menu1:MenuType} level1&quot;</span>&gt;</span>
  ...
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- END Menu Menu1 --&gt;</span></pre></div></div>

<h3>CSS</h3>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#Menu1Container</span> <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">50</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#Menu1Container</span> ul <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">50</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2009/12/04/centering-horizontal-css-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline YUI AutoComplete layout</title>
		<link>http://starikovs.com/2009/11/04/inline-yui-autocomplete-layout/</link>
		<comments>http://starikovs.com/2009/11/04/inline-yui-autocomplete-layout/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 11:28:27 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=71</guid>
		<description><![CDATA[ Recently, i had a problem with YUI AutoComplete layout. I wanted it being inline, fixed width and working with different browsers like IE6/7/8, Opera, FF etc. There were some problems that i solved primarily in CSS. More precisely, i needed an inline YUI AutoComplete layout in such a way that i can place autocomplete [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://starikovs.com/wp-content/uploads/2009/11/yuiautocompletelayout.PNG" alt="Inline YUI AutoComplete layout" title="Inline YUI AutoComplete layout" width="281" height="81" class="alignleft size-full wp-image-73" /> Recently, i had a problem with YUI AutoComplete layout. I wanted it being inline, fixed width and working with different browsers like IE6/7/8, Opera, FF etc. There were some problems that i solved primarily in CSS. More precisely, i needed an inline YUI AutoComplete layout in such a way that i can place autocomplete &lt;input&gt; next to the &lt;label&gt; without a line break. I just set my styles in CSS and override some existing styles and it works ok!</p>
<p><strong>So, problems i had to solve for my needs:</strong></p>
<ul>
<li>an outer container is a DIV so INPUT always goes on the next line</li>
<li>inline-block for DIV doesn&#8217;t work in IE6/7</li>
<li>an outer container has width of 100%</li>
<li>INPUT is absolutely positioned so an outer DIV is collapsed</li>
<li>width of 100% makes INPUT 6px larger then outer DIV in IE6</li>
<li>using inline-block, INPUT aligns vertically on the bottom in IE6</li>
</ul>
<p><span id="more-71"></span></p>
<h3>YUI files to include</h3>
<p>Let&#8217;s begin with files to include:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--CSS file (default YUI Sam Skin) --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/autocomplete/assets/skins/sam/autocomplete.css&quot;</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Dependencies --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/datasource/datasource-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Source file --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/autocomplete/autocomplete-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>Well, i&#8217;m explaining below how i&#8217;ve achieved an inline YUI AutoComplete layout. The code is well-commented to understand what is happening <img src='http://starikovs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>HTML</h3>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- </span>
<span style="color: #808080; font-style: italic;">Let's use SPAN becase it has &quot;display: inline&quot; by default.</span>
<span style="color: #808080; font-style: italic;">IE6/7 can apply &quot;display: inline-block&quot; only for elements</span>
<span style="color: #808080; font-style: italic;">that have &quot;display: inline&quot; by default.</span>
<span style="color: #808080; font-style: italic;">Read more: http://www.quirksmode.org/css/display.html.</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input&quot;</span>&gt;</span>YUI AutoComplete<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;autocomplete&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;results&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
/* creating a data source out of js array */
var ds = new YAHOO.util.LocalDataSource([&quot;apples&quot;, &quot;apricots&quot;, &quot;bananas&quot;]);
&nbsp;
/* creating a yui autocomplete */
var ac = new YAHOO.widget.AutoComplete(&quot;input&quot;, &quot;results&quot;, ds);
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<h3>CSS</h3>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* outer container */</span>
<span style="color: #cc00cc;">#autocomplete</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/* behaving like an inline element */</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -moz-inline-box<span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for FF less then 3.0 */</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span> !important<span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
    <span style="color: #808080; font-style: italic;">/* standard width of a textbox */</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">145px</span><span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* align vertically on the center */</span>
    <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">middle</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* input */</span>
<span style="color: #cc00cc;">#autocomplete</span> input <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/* preventing an outer container DIV collapsing */</span> 
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
    <span style="color: #808080; font-style: italic;">/* tweaking to traditional box model
     * width = border + padding + content
     */</span>
    box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
    -moz-box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
    -webkit-box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
    -ms-box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* ie8 */</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* CSS Expression to calculate width for the input.
     * 2px border + 1px padding + 1px padding + 2px border = 6px.
     * Only for IE6/7 because traditional box model cannot
     * be tweaked by any css property.
     * currentStyle object - IE css styles as specified by 
     * global style sheets, inline styles, and HTML attributes.
     */</span>
    <span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> expression<span style="color: #00AA00;">&#40;</span>parseInt<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">this.parentNode.currentStyle.width</span><span style="color: #00AA00;">&#41;</span>-<span style="color: #cc66cc;">6</span><span style="color: #00AA00;">+</span><span style="color: #ff0000;">'px'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>I&#8217;ve tested this soluting in <strong>FireFox 3.5</strong>, <strong>Opera 10</strong>, <strong>IE 6/7/8</strong>. YUI version i&#8217;m using is <strong>2.8</strong>.</p>
<h3>Further reading:</h3>
<ul>
<li><a href="http://developer.yahoo.com/yui/autocomplete/" target="_blank">YUI 2 Autocomplete</a></li>
<li><a href="http://www.quirksmode.org/css/box.html" target="_blank">CSS Box Models</a></li>
<li><a href="http://www.quirksmode.org/css/display.html" target="_blank">Display declarations</a></li>
<li><a href="http://wiki.orbeon.com/forms/doc/contributor-guide/ie-bugs#TOC-Inline-block" target="_blank">inline-block in IE</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms535889(VS.85).aspx" target="_blank">IE runtimeStyle Object</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms528441(VS.85).aspx" target="_blank">IE currentStyle Object</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms535898(VS.85).aspx" target="_blank">IE style Object</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2009/11/04/inline-yui-autocomplete-layout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
