如何让页面内容在固定位置的按钮后面滚动?

position: fixed我在网页底部有一个按钮。如何使页面内容滚动到按钮后面?这是一张图片,更详细地说明了我的意思:

https://img1.sycdn.imooc.com/652c9c2f0001c48813750592.jpg

这是我尝试过的一些代码:


<!DOCTYPE html>

 <html>

    <head>

        <style type="text/css">

    

            #content {

        

                height: 150px;

                width: 100%;

                background-color:lightpink;

                padding:25px;

                margin:20px;

            

            }

            #header{

                color:white;   

                width:100%;

                height:40px;

                left:0;

                top:0;

                position:fixed;

                background-color:black;

            }

            

            #sidebar{

                top:0;

                left:0;

                width:90px;

                height:100%;

                position:fixed;

                color:white;

                background-color:steelblue;

            }

             

            .btn-bottom-center {

                position: fixed;

                left: 50%;

                bottom: 20px;

                transform: translate(-50%, -50%);

                margin: 0 auto;   

            }

        </style>

    </head>

    <body>

尺寸并不重要。我只需要知道如何使 div 滚动到网页底部固定位置的按钮后面的逻辑。我尝试margin-bottom在页面内容中添加 a 但没有成功。已经谢谢了



qq_花开花谢_0
浏览 69回答 1
1回答

拉丁的传说

div将按钮包裹在具有定义的高度、left: 90px;、right: 0和bottom: 0不透明背景的固定位置:html,body {&nbsp; margin: 0;}#content {&nbsp; height: 150px;&nbsp; width: 100%;&nbsp; background-color: lightpink;&nbsp; padding: 25px;&nbsp; margin: 20px;}#header {&nbsp; color: white;&nbsp; width: 100%;&nbsp; height: 40px;&nbsp; left: 0;&nbsp; top: 0;&nbsp; position: fixed;&nbsp; background-color: black;}#sidebar {&nbsp; top: 0;&nbsp; left: 0;&nbsp; width: 90px;&nbsp; height: 100%;&nbsp; position: fixed;&nbsp; color: white;&nbsp; background-color: steelblue;}.btn-bottom-center {&nbsp; position: fixed;&nbsp; left: 50%;&nbsp; bottom: 20px;&nbsp; transform: translate(-50%, -50%);&nbsp; margin: 0 auto;}.bottom {&nbsp; height: 80px;&nbsp; background: green;&nbsp; position: fixed;&nbsp; bottom: 0;&nbsp; left: 90px;&nbsp; right: 0;}<div id="defaultFragment" fragment="defaultFragment">&nbsp; <div id="header">&nbsp; &nbsp; <center>&nbsp; &nbsp; &nbsp; <h3>Header</h3>&nbsp; &nbsp; </center>&nbsp; </div>&nbsp; <div class="main-container container-fluid">&nbsp; &nbsp; <div class="page-container">&nbsp; &nbsp; &nbsp; <div id="sidebar" th:replace="fragments/sidebar :: sidebarFragment"></div>&nbsp; &nbsp; &nbsp; <div class="page-content">&nbsp; &nbsp; &nbsp; &nbsp; <div class="page-body">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div id="content" layout:fragment="content"></div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div id="content" layout:fragment="content"></div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div id="content" layout:fragment="content"></div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div id="content" layout:fragment="content"></div>&nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </div>&nbsp; &nbsp; <div th:replace="fragments/footer :: footerFragment"></div>&nbsp; </div></div><!--Get Started--><div class="bottom">&nbsp; <input id="get_started" type="button" class="btn-bottom-center" value="GET STARTED" /></div>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5