CSS image Slicing

termasuk cara untuk optimalisasi website,

yaitu mereduksi request yg dilakukan ke server.

pada skenario ini, menggunakan sebuah image sebagai objek dari beberapa url. berikut adalah objek image yang akan digunakan

css_slicing_image

master image yg digunakan

test-3

Note: halaman awal google, ia menggunakan teknik ini untuk mereduksi request HTTP ke server nya


<html><head><title>Css Slicing</title>

<style>

#skyline {

width: 400px;

height: 200px;

background: url(test-3.jpg);

margin: 10px auto; padding: 0;

position: relative;

}

#skyline li {margin: 0; padding: 0; list-style: none; position: absolute; top: 0;}

#skyline li, #skyline a {height: 200px; display: block;}

#panel1b {left: 0; width: 95px;}

#panel2b {left: 96px; width: 75px;}

#panel3b {left: 172px; width: 110px;}

#panel4b {left: 283px; width: 117px;}

#panel1b a:hover { background: transparent url(test-3.jpg) 0 -200px no-repeat; }

#panel2b a:hover { background: transparent url(test-3.jpg) -96px -200px no-repeat; }

#panel3b a:hover { background: transparent url(test-3.jpg) -172px -200px no-repeat; }

#panel4b a:hover { background: transparent url(test-3.jpg) -283px -200px no-repeat; }

</style>

</head>

<body>

<ul id=”skyline”>

<li id=”panel1b”><a href=”#1″></a></li>

<li id=”panel2b”><a href=”#2″></a></li>

<li id=”panel3b”><a href=”#3″></a></li>

<li id=”panel4b”><a href=”#4″></a></li>

</ul>

</body>

</html>


sadur dari : http://www.alistapart.com/articles/sprites


Published by

G3n1k

just to remember what i had known :)

One thought on “CSS image Slicing”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s