Sekarang Beben Koben si bloglang anu ganteng kalem tea akan berbagi trick jQuery Plugin seputaran something on float. Kalian sobat mungkin pernah melihat link share dengan keadaan fixed, jika di scroll diam di tempat. Kalau posisinya pas dan tidak mengganggu pemandangan tidak ada masalah! Jika posisi keberadaannya terlalu ke tengah, tentu saja akan mengganggu penglihatan si pengunjung ;) Untuk mengakali itu semua, mari kita buat pemecahannya dengan full stylish :p
Pertama-tama backup
#outnav {
position: fixed;
left: 0;
top: 99px;
z-index: 9999;
}
#outnav .contain {
margin: 0 auto;
width: 75px;
}
#outnav ul {
height: auto;
list-style: none outside none;
padding: 0;
width: 75px;
}
#outnav ul li {
display: inline;
float: right;
margin: 5px 10px;
}
#outnav a {
background: transparent;
color: #FAFAFA;
float: right;
height: 30px;
}
Perhatikan position: fixed;
left: 0;
top: 99px;
z-index: 9999;
}
#
margin: 0 auto;
width: 75px;
}
#
height: auto;
list-style: none outside none;
padding: 0;
width: 75px;
}
#
display: inline;
float: right;
margin: 5px 10px;
}
#
background: transparent;
color: #FAFAFA;
float: right;
height: 30px;
}
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'></script>
Jangan di pasang bila sudah ada!Markup HTML
<div id='outnav'>
<div class='contain'>
<ul>
<li>
<a href='http://www.delicious.com/YOUR-ACCOUNT' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYvaw6AFKDWNExy9B-YfHtUia4t0uEU43oEpndg3839OzvXZN2HO4fsm4UheSJ7LHW_Jlj5EOeiIwatcu32KsVfUTMGy-MwtJLzU9cwoyiObcArk4uDpp4qtJYQBwS50BWgyTlO1COAjU/s1600/Delicious.png' title='Follow us at Delicious'/></a>
</li>
<li>
<a href='http://digg.com/raezen' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1zv7oUd57b4ZpSs-_HrcemO1w1mAqg1jG9XSjp1_bilvI3ixBzKVEGKiuoE2n2HPFTxcwwVj7xk43lo3s2jQTr-QLd35yBAQu5C8oyK3-exl2-juXMvp1KhOSWLSAXpzlhg-GYmTmLzU/s1600/Digg.png' title='Follow us at Digg'/></a>
</li>
<li>
<a href='http://www.facebook.com/pages/YOUR-ACCOUNT' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieWGm3NQMRu6ovBGoKflB9DVkHU1H-hzh5gnJclAW9PavuIzbUo2QxjQlrGxxrVVvlfC4YLjgSqTUI3yD0Zf95yWH49zyXmulP0Z-pJfc2d3MIGy0-Lh_Mz0LWUsg7QCGyg-nWJsNC8Vo/s1600/Facebook.png' title='Follow us at Facebook'/></a>
</li>
<li>
<a href='http://www.stumbleupon.com/stumbler/YOUR-ACCOUNT/' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi282T-5QgHTcq5ZD5OFBP4Rh925St9FjFZ-70s1BF0-Twb42xEKbb-f1iVzvxpxfgBFS5yzHiKMlasGV_8IXkkkz_yqfODYk5bHIJgHd-ca_TO5q_mbYb8-d9jRKtyNCY8g0n3qKv3E_Y/s1600/StumbleUpon.png' title='Follow us at StumbleUpon'/></a>
</li>
<li>
<a href='http://twitter.com/YOUR-ACCOUNT' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaTluKVgV7bhZPomVFBGYH1R_pnAZt6W82flE3emhZ8zmbn9p_FUmT5FoCmXOSJCyEukuQVxjlK5722_3-Z9_lvu4xaXCAeZekXySIh66BrQ5JT7CnJ1mdMlbGdMGfo3vRS28fqQWfq-4/s1600/Twitter.png' title='Follow us at Twitter'/></a>
</li>
</ul>
</div>
</div>
<div class='contain'>
<ul>
<li>
<a href='http://www.delicious.com/YOUR-ACCOUNT' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYvaw6AFKDWNExy9B-YfHtUia4t0uEU43oEpndg3839OzvXZN2HO4fsm4UheSJ7LHW_Jlj5EOeiIwatcu32KsVfUTMGy-MwtJLzU9cwoyiObcArk4uDpp4qtJYQBwS50BWgyTlO1COAjU/s1600/Delicious.png' title='Follow us at Delicious'/></a>
</li>
<li>
<a href='http://digg.com/raezen' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1zv7oUd57b4ZpSs-_HrcemO1w1mAqg1jG9XSjp1_bilvI3ixBzKVEGKiuoE2n2HPFTxcwwVj7xk43lo3s2jQTr-QLd35yBAQu5C8oyK3-exl2-juXMvp1KhOSWLSAXpzlhg-GYmTmLzU/s1600/Digg.png' title='Follow us at Digg'/></a>
</li>
<li>
<a href='http://www.facebook.com/pages/YOUR-ACCOUNT' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieWGm3NQMRu6ovBGoKflB9DVkHU1H-hzh5gnJclAW9PavuIzbUo2QxjQlrGxxrVVvlfC4YLjgSqTUI3yD0Zf95yWH49zyXmulP0Z-pJfc2d3MIGy0-Lh_Mz0LWUsg7QCGyg-nWJsNC8Vo/s1600/Facebook.png' title='Follow us at Facebook'/></a>
</li>
<li>
<a href='http://www.stumbleupon.com/stumbler/YOUR-ACCOUNT/' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi282T-5QgHTcq5ZD5OFBP4Rh925St9FjFZ-70s1BF0-Twb42xEKbb-f1iVzvxpxfgBFS5yzHiKMlasGV_8IXkkkz_yqfODYk5bHIJgHd-ca_TO5q_mbYb8-d9jRKtyNCY8g0n3qKv3E_Y/s1600/StumbleUpon.png' title='Follow us at StumbleUpon'/></a>
</li>
<li>
<a href='http://twitter.com/YOUR-ACCOUNT' target='new'><img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaTluKVgV7bhZPomVFBGYH1R_pnAZt6W82flE3emhZ8zmbn9p_FUmT5FoCmXOSJCyEukuQVxjlK5722_3-Z9_lvu4xaXCAeZekXySIh66BrQ5JT7CnJ1mdMlbGdMGfo3vRS28fqQWfq-4/s1600/Twitter.png' title='Follow us at Twitter'/></a>
</li>
</ul>
</div>
</div>
jQuery Plugin
SAVE.<script type='text/javascript'>
//<![CDATA[
jQuery(window).scroll(function () {
if (jQuery(this).scrollTop() !== 0) {
jQuery('#outnav').fadeIn();
} else {
jQuery('#outnav').fadeOut();
}
});
//]]>
</script>
Dengan begitu saja kalian sudah mempunyai trik apabila kita scroll ke atas, maka akan menghilang. Lakukan scroll mouse pada demo
http://jsbin.com/ikawox
Apakah cuma segitu!!! Oh nooo, kurang style dong ah :)) Kemon lanjut...Versi pertama cuma hidden ketika kita sudah melakukan scroll sekali saja. Dan itupun masih terlihat sesuatunya (link share)! Gantikan jQuery pluginnya saja oleh sobat dengan ini ya
Happy jQuery \m/
DONE.<script type='text/javascript'>
//<![CDATA[
$(function() {
$(window).scroll(function(){
var scrollTop = $(window).scrollTop();
if(scrollTop !== 0)
$('#outnav').stop().animate({'opacity':'0.2'},500);
else
$('#outnav').stop().animate({'opacity':'1'},500);
});
$('#outnav').hover(
function (e) {
var scrollTop = $(window).scrollTop();
if(scrollTop !== 0){
$('#outnav').stop().animate({'opacity':'1'},500);
}
},
function (e) {
var scrollTop = $(window).scrollTop();
if(scrollTop !== 0){
$('#outnav').stop().animate({'opacity':'0'},500);
}
}
);
});
//]]>
</script>
http://jsbin.com/ekuges
Silahkan mau pakai yg mana ;;)Happy jQuery \m/
Tidak ada komentar:
Posting Komentar