Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

[jQuery] Scroll Up Headline Reader

2011-07-11 by 편리

출처 : http://www.learningjquery.com/2006/10/scroll-up-headline-reader

사이트 오픈이 코 앞인데 아직도 코딩 작업을 하고 있으니.. 정말 큰 일이 아닐 수 없다. 이래서는 안되는데..
어쨌든 사이트 작업을 하다 보니 공지사항의 제목을 사이트 상단에 보여줘야 하는데 이때 위로 스크롤링이 되어야
하기 때문에 이미 만들어진 소스가 있긴 하지만 jQuery로 간단하게 만들 수 있지 않을까 하는 생각에 무조건 도전..
다행히 이미 만들어둔 코드가 있어서 그걸 참고해서 무사히 해결할 수 있었다.

우선 작업을 하기 전에 CSS를 추가해줘야 한다.

#scrollup { float: left; position: relative;    overflow: hidden;     height: 17px;    width: 450px; }
#scrollup_icon { float: left; width: 54px; }
.headline {    position: absolute; top: 40px;     left: 5px; width:440px; white-space: nowrap; overflow: hidden; }

<div id=”scrollup_icon”><img src=”./main_top_notice.gif” align=”absmiddle”></div>
<div id=”scrollup”>
    <div class=”headline”>반포 자이 아파트 32평형 시공비 30% 할인 10가구 한정 – 도원종합장식</div>
    <div class=”headline”>반포 자이 아파트 32평형 시공비 30% 할인 10가구 한정</div>
    <div class=”headline”>반포 자이 아파트 32평형</div>
</div>

다음은 스크롤링 부분을 처리하는 스크립트이다.

<script type=”text/javascript”>
// 탑이벤트 스크롤UP
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

$(document).ready(function(){
  headline_count = $(“div.headline”).size();
  $(“div.headline:eq(“+current_headline+”)”).css(‘top’,’3px’);

  headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
  $(‘#scrollup’).hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
    headline_rotate();
  });
});

function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count;
  $(“div.headline:eq(” + old_headline + “)”).animate({top: -35},”slow”, function() {
    $(this).css(‘top’,’40px’);
    });
  $(“div.headline:eq(” + current_headline + “)”).show().animate({top: 3},”slow”);
  old_headline = current_headline;
}
</script>

요정도의 코드로 간단하게 jQuery를 이용해서 위로 스르콜링 되는 부분을 만들었다.

Post navigation

Previous Post:

에휴~ 잘 좀 해주세요

Next Post:

집에서도 코딩

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • SK 세븐모바일 유심 셀프교체
  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes