JavaScript & jQuery | 스크롤바 상단 고정메뉴
작성자

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Insert title here</title>
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
        }

        div {
            text-align: center;
        }

        #wrapper {
            width: 100%;
            overflow: hidden;
            margin: 0 auto;
        }

        #wrapper #header {
            background-color: #ffff00;
            color: #bbb;
            height: 100px;
        }

        #wrapper #menu {
            background-color: #bbb;
            height: 50px;
            color: #fff;
            width: 800px;
        }

        #wrapper #contents {
            background-color: #eee;
            height: 1000px;
        }
    </style>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            var menupos = $("#menu").offset().top;
            $(window).scroll(function() {
                if ($(window).scrollTop() >= menupos) {
                    $("#menu").css("position", "fixed");
                    $("#menu").css("top", "0");
                } else {
                    $("#menu").css("position", "relative");
                    $("#menu").css("top", "");
                }
            });
        });
    </script>

</head>

<body>
    <div id="wrapper">
        <div id="header">header</div>
        <div id="menu">menu</div>
        <div id="contents">
            contents
        </div>
    </div>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>

</html>

 

댓글목록

등록된 댓글이 없습니다.

총 게시물 93 개, 페이지 1 RSS
제목 작성자
기타 인스타 토큰받아오기
기타 sns 공유하기 소스 - 라인, 폴라, 카톡, 카스, 밴드, 핀터레스트, 구글플러스, 네이버블로그, 트위터, 페이스북 H
JavaScript & jQuery jQuery 다수의 Ajax 요청 처리 관련 H
JavaScript & jQuery parent() 활용 - 클릭한 클래스의 상위 클래스 찾아서 hide() H
JavaScript & jQuery 스크롤바 상단 고정메뉴 H
JavaScript & jQuery jquery 해당 클래스안에서 iframe name찾기, iframe과 iframe간 제어 H
JavaScript & jQuery jquery 파일업로드 미리보기 H
JavaScript & jQuery 'jquery date picker' 시작날짜 이후로 마지막날짜 달력 보이기 H
JavaScript & jQuery 정수로 반환하면서 NaN일때 0으로 처리 H
오류해결 Strict Standards: Assigning the return value of new by reference is deprecated in /home/goodbook/pub… H
오류해결 array_keys() [function.array-keys]: The first argument should be an array in H
오류해결 phpize 실행 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF enviro… H
오류해결 [phpmyadmin]mysqli 확장모듈을 불러올 수 없습니다.<br />PHP 환경설정을 검사하십시오 H
오류해결 Apache 재시작시 (98)Address already in use: make_sock:could not bind to address 0.0.0.0:80 H
오류해결 httpd: Syntax error on line 106 of /usr/local/server/apache/conf/httpd.conf: Cannot load /usr/local/… H
게시물 검색