<?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>arif.suparlan.com &#187; Design</title>
	<atom:link href="http://arif.suparlan.com/category/design/feed" rel="self" type="application/rss+xml" />
	<link>http://arif.suparlan.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 01 Sep 2010 21:28:31 +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>Resize gambar proporsional &amp; posisi tengah dengan CSS &amp; Javascript (Update)</title>
		<link>http://arif.suparlan.com/2010/08/18/resize-proporsional-posisi-center-dengan-css-javascript</link>
		<comments>http://arif.suparlan.com/2010/08/18/resize-proporsional-posisi-center-dengan-css-javascript#comments</comments>
		<pubDate>Wed, 18 Aug 2010 15:16:46 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Iseng]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[center]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[overflow hidden]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[skala]]></category>

		<guid isPermaLink="false">http://arif.suparlan.com/?p=259</guid>
		<description><![CDATA[Saya hampir gila mencoba me-resize dan memposisikan tengah beberapa gambar di dalam div yang mempunyai property overflow: hidden. Terlalu berlebihan ya? hehehe&#8230; Tapi memang sulit. Ukuran gambar tersebut berbeda-beda, portrait atau landscape, yang jelas dia lebih besar dari ukuran div itu. Saya belum bisa ngakalinnya bermodalkan CSS saja. Meskipun mentok dengan CSS, saya akhirnya ngakalin [...]]]></description>
			<content:encoded><![CDATA[<p>Saya hampir gila mencoba me-<em>resize </em>dan memposisikan tengah beberapa gambar di dalam <em>div </em>yang mempunyai <em>property overflow: hidden</em>. Terlalu berlebihan ya? hehehe&#8230; Tapi memang sulit. Ukuran gambar tersebut berbeda-beda, portrait atau landscape, yang jelas dia lebih besar dari ukuran div itu. Saya belum bisa ngakalinnya bermodalkan CSS saja.<span id="more-259"></span></p>
<p>Meskipun mentok dengan CSS, saya akhirnya ngakalin dengan bantuan Javascript. Dengan memanfaatkan Javascript saya bisa untuk merubah ukuran dan posisi gambar secara dinamis. Bisa lebih dari itu sih, tapi untuk pemula seperti saya ini bisa sangat membantu melayout halaman.</p>
<p>Dulu saya pernah buat script untuk <a href="http://arif.suparlan.com/2009/09/11/resize-crop-gambar-proporsional-di-codeigniter" target="_blank">Resize &amp; crop gambar dengan Codeigniter</a>. Nah script ini memakai hitung-hitungan yang sama. Kalau Codeigniter kalkulasinya oleh PHP di sisi server, yang ini di sisi client/browser. Cara ini bisa dipermudah dengan menggunakan framework Javascript. Saya belum coba, tapi kalau ada cara yang lebih mudah lagi, mohon dipost di sini. Makasih.</p>
<p>Di bawah berikut kira-kira contoh scriptnya. Kedua gambar yang berukuran besar dengan orientasi yang berbeda, portrait dan landscape ini saya letakkan sebagai icon dalam div dengan property overflow hidden. Prosesnya mudah, tetapi agak panjang, yaitu membandingkan rasio dua ukuran untuk menentukan orientasi kemudian me-resize dan menghitung posisi tengah. Ini contohnya: <a href="http://arif.suparlan.com/demo/resize_position_center/" target="_blank">Demo</a>.</p>
<pre>&lt;html&gt;
&lt;head&gt;
 &lt;title&gt;Resize proporsional &amp; posisi center dengan Javascript&lt;/title&gt;
&lt;style type="text/css"&gt;
.test {
 border:1px solid;
 margin-top:100px;
 margin-left:250px;
 width:150px;
 height:150px;
 overflow: hidden;
 float: left;
}

.test img {
}

&lt;/style&gt;

&lt;script type="text/javascript"&gt;
 window.onload = function() {
 var $images = document.getElementsByTagName('img');
 $x=150;
 $y=150;

 for($i=0; $i&lt;$images.length; $i++)
 {
 $new_size = resize_min($images[$i].width, $images[$i].height, $x, $y);

 $images[$i].style.width = $new_size[0];
 $images[$i].style.height = $new_size[1];
 $images[$i].style.marginLeft = -(($new_size[0]-$x)*.25) + "px";
 $images[$i].style.marginTop = -(($new_size[1]-$y)*.25) + "px";
 }

 function resize_min($x0, $y0, $x1, $y1) {
 $xs=$x0/$x1;
 $ys=$y0/$y1;

 if ($ys&gt;$xs){
 $x2 = $x1;
 $y2 = $x1 * ($y0/$x0);
 }
 else {
 $x2 = $y1 * ($x0/$y0);
 $y2 = $y1;
 }

 return [$x2, $y2];
 }
 }
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Resize proporsional &amp; posisi center dengan Javascript&lt;/h1&gt;

&lt;div&gt;
 &lt;img src="img01.jpg" /&gt;
&lt;/div&gt;
&lt;div&gt;
 &lt;img src="img02.jpg" /&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Update berikut untuk penggunaan dengan jQuery. Ada beberapa tambahan script untuk mengukur dimensi ketika dalam keadaan gambar hidden.</p>
<pre>$(document).ready(function() {
 $('img').each(function() {
 var x = 150;
 var y = 150;
 var ratio = x/y;

 if ($(this).height() &gt; 0) {
 var width = $(this).width();
 var height = $(this).height();
 } else {
 var elem_clone = $(this).clone()
 .attr("id", false)
 .css({visibility:"hidden", display:"block", position:"absolute"});
 $("body").append(elem_clone);
 var width = elem_clone.width();
 var height = elem_clone.height();
 elem_clone.remove();    
 }

 $new_size = resize_min(width, height, x, y);

 $(this).css("width", $new_size[0]);
 $(this).css("height", $new_size[1]);
 $(this).css("marginLeft", -(($new_size[0]-x)*.5) + "px");
 $(this).css("marginTop", -(($new_size[1]-y)*.5) + "px");
 });
 });</pre>
]]></content:encoded>
			<wfw:commentRss>http://arif.suparlan.com/2010/08/18/resize-proporsional-posisi-center-dengan-css-javascript/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Your Website on Different Browsers</title>
		<link>http://arif.suparlan.com/2008/10/30/check-your-website-on-different-browsers</link>
		<comments>http://arif.suparlan.com/2008/10/30/check-your-website-on-different-browsers#comments</comments>
		<pubDate>Wed, 29 Oct 2008 19:52:05 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Free/Open Source]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://arif.suparlan.com/?p=109</guid>
		<description><![CDATA[Browser compatibility is about how your website is displayed on different web browsers. This is much about user experience testing to ensure users have the same visual experiences and how it functionally behaves and responds the same way across different browsers. It is really frustrating when your website looks fine on one, but ruined on [...]]]></description>
			<content:encoded><![CDATA[<p>Browser compatibility is about how your website is displayed on different web browsers. This is much about user experience testing to ensure users have the same visual experiences and how it functionally behaves and responds the same way across different browsers. It is really frustrating when your website looks fine on one, but ruined on other browsers. And there are a lot of types of browsers and they have different ways of interpreting the codes.<span id="more-109"></span></p>
<p>I have my own way for this kind of situation. Check the web&#8217;s stats. For example, according to Google Analytics for this website, the most used browsers are Firefox, IE, Opera, Mozilla Compatible, Safari and Chrome. Then I would manually view the web on different browsers. For IE special case, it has many versions, I use <a href="http://tredosoft.com/Multiple_IE" target="_blank">Tredosoft</a> which enable to run multiple IE versions on your PC.</p>
<p><img class="alignnone size-medium wp-image-112" style="border: 0; margin-left: 7px; margin-right: 7px; margin-top: 2px; margin-bottom: 2px;" title="browsershots" src="http://arif.suparlan.com/wp-content/uploads/2008/10/browsershots-300x211.jpg" alt="browsershots.org" width="300" height="211" /></p>
<p>Maybe you don&#8217;t want to install anything, or you want to know how it looks not only on different browser, but on different OS&#8217; too. This is very interesting, I found this site when Googling about cross browser compatibility. There are some commercial online services to check browser compatibility, but <a href="http://browsershots.org/" target="_blank">Browsershots.org</a> is free open-source online service for website compatibility testing. Just enter the URL, select the browser and OS, and it will queue the screenshots. Now maybe you should try it to your website.</p>
]]></content:encoded>
			<wfw:commentRss>http://arif.suparlan.com/2008/10/30/check-your-website-on-different-browsers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keep it Simple, Stupid</title>
		<link>http://arif.suparlan.com/2007/07/23/keep-it-simple-stupid</link>
		<comments>http://arif.suparlan.com/2007/07/23/keep-it-simple-stupid#comments</comments>
		<pubDate>Mon, 23 Jul 2007 10:36:23 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Iseng]]></category>

		<guid isPermaLink="false">http://arif.suparlan.com/?p=33</guid>
		<description><![CDATA[No, this ain&#8217;t about PHP&#8217;s KISS thing. It&#8217;s about my blog&#8217;s new theme design. I know it sucks, I don&#8217;t care, I got tired with all these theme designs, tired with rearranging CSS, etc. so I&#8217;m keeping it simple this time. This KISS thing I&#8217;m gonna keep in mind, I mean for everything. Only one [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://arif.suparlan.com/wp-content/uploads/2007/07/wp_arif01.thumbnail.jpg" align="left" height="126" hspace="7" vspace="2" width="128" />No, this ain&#8217;t about PHP&#8217;s KISS thing. It&#8217;s about my blog&#8217;s new theme design. I know it sucks, I don&#8217;t care, I got tired with all these theme designs, tired with rearranging CSS, etc. so I&#8217;m keeping it simple this time. This KISS thing I&#8217;m gonna keep in mind, I mean for everything.</p>
<p>Only one coloumn, header on top, then menu, content, and footer. The menu is slide-able, it contains search form, categories, and links. Thanks to Anas for telling me about these great joomla templates and mootools, well now this is not simple. Heheh&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://arif.suparlan.com/2007/07/23/keep-it-simple-stupid/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
