これにはプラグインは必要ありません。 CSSはロゴを固定したままにすることができ、ユーザがページをスクロールし始めると、JavaScriptの要素を使って表示を変更することができます。あなたのロゴはロゴのIDを持っていると仮定すると
、CSSは次のようになります。
#logo {
top: 0;
position: fixed;
}
あなたが、あなたがこのような何か行うことができますjQueryのを使用している表示されますので:
$(function() {
// gets a reference to the document based on which browser is being used
var oDoc = $.browser.msie === true ? window : document;
// event handler for when the user scrolls
$(oDoc).scroll(function() {
// if the user is at the top, display the whole image
if($(this).scrollTop() === 0) {
$('#logo').css('margin-top', 0);
// otherwise, pull the image up a single em (200 is arbitrary)
} else if($(this).scrollTop() > 200) {
$('#logo').css('margin-top', '-1em');
}
});
});
出典
2011-03-09 13:25:39
Tom
働いていました完全に、ありがとう!私が想像したよりはるかに簡単です。 – spiral