공유 및 소셜 아이콘이 포함 된 막대가 있습니다. 이 막대는 다음과 같이 게시물 제목 아래에 배치됩니다.스크롤시 요소의 위치를 변경하는 jQuery 코드
<div class="post" id="post-<?php the_ID(); ?>">
<div class="title">
<h1><?php the_title(); ?></h1>
</div>
<div class="sharelinks">
<ul>
<li><a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-count="horizontal">Tweet</a></li>
<li><div class="fb-like" data-href="<?php the_permalink(); ?>" data-send="false" data-layout="button_count" data-show-faces="false" data-font="arial"></div></li>
<li><g:plusone size="medium" href="<?php the_permalink(); ?>/"></g:plusone></li>
<li><a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo urlencode(sofa_image_src('full')); ?>&description=<?php echo urlencode(get_the_title($post->ID)); ?>" class="pin-it-button" count-layout="horizontal">Pin It</a></li>
<li><su:badge layout="1"></su:badge></li>
</ul>
</div>
</div>
그건 내 html입니다. 그리고 "sharelinks"내 CSS는 다음과 같습니다
.sharelinks {
padding: 10px 20px;
background: #f1f1f1;
box-shadow: 0 1px #fff inset, 0 -1px #fff inset;
border-bottom: 1px solid #ddd;
position: relative;
}
내가 달성하고자하는 무엇? - 사용자가 범위를 넘어서 스크롤하고 항상 페이지 상단 (고정 위치)에 놓았을 때 sharelinks div의 위치를 변경하고 사용자가 그 위치까지 뒤로 스크롤 할 때 기본 위치로 되돌리려합니다. 사용자가 스크롤하면 "넘어"스크롤하지 않는 한 막대가 페이지의 맨 위에 고정되어 나타나는 한 막대를 만드는 방법입니다.
HEADER에 대해 완벽하게 작동하는 유사한 코드가 있지만이 요소에는 동일한 코드가 작동하지 않습니다. 내 머리글이 페이지 맨 위에 있기 때문에 생각합니다.
나는 도움이나 아이디어가 필요하다. 나는 그 효과를 만드는 법을 배웠다.
// fixed navigation
var yOffset = $("#header").offset().top;
$(window).scroll(function() {
if ($(window).scrollTop() > yOffset) {
$("#header").css({
'top': 0,
'position': 'fixed'
});
} else {
$("#header").css({
'top': yOffset + 'px',
'position': 'absolute'
});
}
});
와이 : http://stackoverflow.com/questions/6408713/div- that-follows-scroll-not-positionfixed # 7237089 jQuery 플러그인을 사용하고 구현하기가 매우 쉽습니다. –
이 도움이 될 수 있습니다 : http://stackoverflow.com/questions/11971475/setting-css-value-limits-of-the-window-scrolling-animation/11971912#11971912 –