테스트 사이트 - 개발 중인 베타 버전입니다

특정 지점을 넘어가면 나타나는 요소 채택완료

쪼탱 2년 전 조회 1,215

https://shopping.naver.com/window-products/outlet/8016991914?NaPm=ct%3Dldmvhl2k%7Cci%3Dshoppingwindow%7Ctr%3Dswl%7Chk%3De2c6ca47f487e5bb1e2490056e0ed7f454a8b388%7Ctrx%3D

 

네이버쇼핑의 한 페이지 입니다. 아래 상품은 저랑 전혀 상관없음다..

스크롤을 어느정도 내렸을때 상단에 구매하기 html요소들이 출력이 되는데 이거와 비슷한 예제가 있을까요?

 

 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
2년 전

</p>

<p><!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8" />

        <title>_productTabContainer</title>

        <style>

        * { margin: 0; padding: 0; }

        #_productTabContainer {

            position: fixed;

            border-bottom: 1px solid #000;

            width: 100%;

            height: 7.25em;

        }

        #_productTabContainer .pdinfo {

            display: none;

            width: 96%;

            margin: auto;

        }

        #_productTabContainer .menubar {

            position: absolute;

            left: 50%;

            bottom: 0;

            margin-left: -48%;

            list-style-type: none;

            display: flex;

            width: 96%;

        }

        #_productTabContainer .menubar li {

            flex: 1;

        }

        #_productTabContainer .menubar a {

            padding: 0.7em 0;

            display: block;

            text-align: center;

            text-decoration: none;

            background-color: #eee;

            color: #000;

            font-weight: bold;

        }

        #_productTabContainer .menubar a.active {

            background-color: darkslateblue;

            color: #fff;

        }

        </style>

        <script type="text/javascript">

        document.addEventListener("DOMContentLoaded", function () {

            var ct = document.getElementById("_productTabContainer");

            var ct_top = ct.offsetTop;

            var pdinfo = ct.querySelector('.pdinfo');

            this.addEventListener("scroll", function () {

                if (ct_top - document.documentElement.scrollTop > 0) {

                    ct.style.top = (0, ct_top - document.documentElement.scrollTop) + "px";

                    pdinfo.style.display = 'none';

                } else {

                    ct.style.top = "0px";

                    pdinfo.style.display = 'block';

                }

            }, false);

        }, false);

        </script>

    </head>

    <body>

        



















        <div id="_productTabContainer">

            <div class="pdinfo">image text button</div>

            <ul class="menubar">

                <li><a href="#" class="active">상세정보</a></li>

                <li><a href="#">리뷰</a></li>

                <li><a href="#">Q&A 0</a></li>

            </ul>

        </div>

        



















        



















        



















        



















        



















        



















    </body>

</html></p>

<p>

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인