Jump to content
Fórum Script Brasil
  • 0

não consigo utilizar position: sticky como eu queria


Question

Estou querendo deixar um rodapé fixo no topo a medida que o mesmo alcança o topo da página, porém estou encontrando dificuldades ao utilizar position: sticky, segue o código completo, se eu colocar a configuração de sticky na classe .side-column funciona bem, porém quero apenas no footer, alguém saber como resolver?

<!DOCTYPE html>
<html>
<head>
    <style>
        .wideBody .side-column {
            float: right;
            order: 2;
            width: 300px;
        }              
                .wideBody .side-column footer {
                    position: sticky;
                    position: -webkit-sticky;
                    top: 0;
                }
        .wideBody .main-column {
            align-self: flex-start;
            float: left;
            width: 500px;
            border: 2px solid #4CAF50;
        }
        .resultados {
            border: 2px solid #4CAF50;
            margin-bottom:25px;
            position:relative;
        }
        footer {
            border: 2px solid #4CAF50;
        }
        </style>
</head>
<body class="wideBody">
    <main>
        <div>
            <div class="main-column">
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
                coluna principal<br />
            </div>
            <aside class="side-column">
                coluna auxiliar
                <div class="resultados">
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                    1 -> 2<br />
                </div>
                <footer>
                    rodape fixo
                </footer>
            </aside>
        </div>
    </main>
</body>
</html>

 

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Resolvido

Consegui fazer o que eu queria, segue o código funcionando, talvez alguém possua a mesma dúvida: 

<!DOCTYPE html>
<html>
<head>
    <style>
        
        .wideBody .main-content {
            display: flex;
            justify-content: space-between
        }
            .wideBody .side-column {
                float: right;
                order: 2;
                width: 300px;
            }

                .wideBody .side-column footer {
                    position: sticky;
                    position: -webkit-sticky;
                    top: 0;
                }

            .wideBody .main-column {
                align-self: flex-start;
                float: left;
                width: 500px;
                border: 2px solid #4CAF50;
                height: 5000px
            }

            .resultados {
                border: 2px solid #4CAF50;
                margin-bottom: 25px;
                position: relative;
                height: 120px
            }

            footer {
                border: 2px solid #4CAF50;
                height:100px;
            }
        </style>
</head>
<body class="wideBody">
    <div class="main-content">
        <div class="main-column">
            coluna principal<br />
        </div>
        <aside class="side-column">
            coluna auxiliar
            <div class="resultados">
                Resultados
            </div>
            <footer>
                rodape fixo
            </footer>
        </aside>
    </div>
</body>
</html>

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149288
    • Total Posts
      645685
×
×
  • Create New...