页脚html也显示在[closed]以下

问题描述 投票:-1回答:1

我在尝试正确放置页脚时遇到困难。

我想将页脚放在底部(有效),但实际上它也显示在下方,我不知道为什么...如果我的身体太长,我可以向下滚动,但情况并非如此时,我可以不滚动。找不到页边距或与页脚相关的问题,可能会导致此问题。

.footer {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    background-color: #24292e;
    color: rgba(255,255,255,0.75);
    text-align: center;
}
* {
    box-sizing: border-box;
}

html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    font-family: Poppins;
    font-weight: 400;
    background: url(../images/background.jpg);
    background-position: center;
    background-size: cover;
    overflow-y: scroll;
}

nav {
    padding: 8px;
}

.logo {
    float: left;
    padding: 8px;
    margin-left: 16px;
}

    .logo a {
        color: #ffffff;
        text-transform: uppercase;
        font-weight: 700;
        font-size: 22px;
        letter-spacing: 0px;
        text-decoration: none;
    }

nav ul {
    float: right;
}

    nav ul li {
        display: inline-block;
        float: left;
    }

        nav ul li:not(:first-child) {
            margin-left: 48px;
        }

        nav ul li:last-child {
            margin-right: 24px;
        }

        nav ul li a {
            display: inline-block;
            outline: none;
            color: #000;
            text-transform: uppercase;
            text-decoration: none;
            font-size: 14px;
            letter-spacing: 1.2px;
            font-weight: 600;
        }

@media screen and (max-width: 864px) {
    .logo {
        padding: 0;
    }

    .nav-wrapper {
        position: fixed;
        top: 0px;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        background: #fff;
        opacity: 0;
        transition: all 0.2s ease;
    }

        .nav-wrapper ul {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 100%;
        }

            .nav-wrapper ul li {
                display: block;
                float: none;
                width: 100%;
                text-align: right;
                margin-bottom: 10px;
            }

                .nav-wrapper ul li:nth-child(1) a {
                    transition-delay: 0.2s;
                }

                .nav-wrapper ul li:nth-child(2) a {
                    transition-delay: 0.3s;
                }

                .nav-wrapper ul li:nth-child(3) a {
                    transition-delay: 0.4s;
                }

                .nav-wrapper ul li:nth-child(4) a {
                    transition-delay: 0.5s;
                }

                .nav-wrapper ul li:not(:first-child) {
                    margin-left: 0;
                }

                .nav-wrapper ul li a {
                    padding: 10px 24px;
                    opacity: 0;
                    color: #000;
                    font-size: 14px;
                    font-weight: 600;
                    letter-spacing: 1.2px;
                    transform: translateX(-20px);
                    transition: all 0.2s ease;
                }

    .nav-btn {
        position: fixed;
        right: 10px;
        top: 10px;
        display: block;
        width: 48px;
        height: 48px;
        cursor: pointer;
        z-index: 9999;
        border-radius: 50%;
    }

        .nav-btn i {
            display: block;
            width: 20px;
            height: 2px;
            background: #ffffff;
            border-radius: 2px;
            margin-left: 14px;
        }

            .nav-btn i:nth-child(1) {
                margin-top: 16px;
            }

            .nav-btn i:nth-child(2) {
                margin-top: 4px;
                opacity: 1;
            }

            .nav-btn i:nth-child(3) {
                margin-top: 4px;
            }
}

#nav:checked + .nav-btn {
    transform: rotate(45deg);
}

    #nav:checked + .nav-btn i {
        background: #000;
        transition: transform 0.2s ease;
    }

        #nav:checked + .nav-btn i:nth-child(1) {
            transform: translateY(6px) rotate(180deg);
        }

        #nav:checked + .nav-btn i:nth-child(2) {
            opacity: 0;
        }

        #nav:checked + .nav-btn i:nth-child(3) {
            transform: translateY(-6px) rotate(90deg);
        }

#nav:checked ~ .nav-wrapper {
    z-index: 9990;
    opacity: 1;
}

    #nav:checked ~ .nav-wrapper ul li a {
        opacity: 1;
        transform: translateX(0);
    }

.hidden {
    display: none;
}

.txt {
    color:white;
    font-size:16px;
}

.container {
    margin-top: 1%;
}

.border-container {
    background-color: rgba(0, 0, 0, 0.7);
    margin-top: 7%;
    margin-bottom:1%;
    margin-left: 15%;
    margin-right: 15%;
    padding: 5px;
    border-radius: 5px;
    max-height: 690px;

}

.container-text {
    margin-top: 1%;
    margin-bottom: 1%;
    margin-left: 1%;
    margin-right: 1%;
    padding: 1%;
    border-radius: 3px;
}

.text {
    font-size: 14px;
    color: white;
}

.h1 {
    color: white;
}

.logo-herbalife {
    height: 50px;
    width: 50px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 5%;
}

.social-logo {
    list-style: none;
    padding-right: 30px;
    display: inline;
    margin-right:11px;
}

.fab {
    color: white;
}

.far {
    color: white;
}
* {
    margin: 0;
}

.active, .btn:hover {
    border-bottom: 2px solid #65bb00;
}
.blockquote-footer {
    background-color: rgba(0, 0, 0, 0.7);
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    text-align: center;
    padding: 5px 0 5px 0;
    clear: both;
}
.well
{
    position: relative;
}
.title-footer {
    color: white;
    font-weight: 700;
    font-size: 22px;
}

.text-footer {
    margin: 0 0 12px 0;
    color: white;
    font-weight: 600;
    font-size: 11px;
}

.gallery {
    background-color: rgba(0, 0, 0, 0.7);
    margin-top: 7%;
    margin-bottom: 4%;
    margin-left: 15%;
    margin-right: 15%;
    padding: 10px;
    border-radius: 3px;
    text-align: center;
}

.gallery img{
    transition: 0.7s;
    padding: 10px;
    width: 300px;
    height: 300px;
}

.gallery img:hover{
    filter: grayscale(50%);
    transform: scale(1.1);
}
/*.ifooter
{
    margin-bottom: -60px;
}*/
.topnav a:hover {
    border-bottom: 5px solid #65bb00;
    padding-bottom: 8px;
    transition: all 0.3s linear;
    -webkit-transition: all 0.3s linear;
    -moz-transition: all 0.3s linear;
}

.topnav a.active {
   border-bottom: 5px solid #65bb00;
   padding-bottom:8px;
}
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Accueil - Fab h24</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link href="https://fonts.googleapis.com/css?family=Poppins&display=swap" rel="stylesheet">
    <script src="https://kit.fontawesome.com/6d0f7aa58c.js" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>

<body class="body">
    <div class="container">
        <nav>
            <input type="checkbox" id="nav" class="hidden">
            <label for="nav" class="nav-btn">
                <i></i>
                <i></i>
                <i></i>
            </label>
            <div class="logo">
                <a href="index.html"><span style="color: #65bb00;">N</span>ame</a>
            </div>

            <div id="myDIV" class="nav-wrapper topnav">
                <ul>
                    <li><a href="index.html" class="txt active">Home</a></li>
                    <li><a href="coach.html" class="txt">Coaching</a></li>
                    <li><a href="programmes.html" class="txt">Produits</a></li>
                    <li><a href="galerie.html" class="txt">Galerie photos</a></li>
                    <li><a href="contact.html" class="txt">Contact</a></li>
                </ul>
            </div>
        </nav>
    </div>

    <div class="border-container">
        <div class="container-text">
            <h1 class="h1">Bienvenue chez <span style="color: #65bb00;">NAME</span> !</h1><br />
            <div class="text">
                Absorbés par le travail et la vie familiale, de nombreuses personnes éprouvent à l’heure actuelle des difficultés à trouver le temps et se motiver pour faire du sport.<br /><br />

                <span style="color: #65bb00;">NAME</span> vous accompagne pendant vos sessions de sport et vous aide à accomplir tous vos objectifs.<br /><br />

                Un programme complet et personnalisé mis au point par votre coach vous permet de travailler d’une façon précise et déterminée.<br /><br />

                Si vous souhaitez en savoir plus, n’hésitez pas à nous contacter.<br /><br />

                Cours individuels, cours collectifs, coaching d’entreprise, initiation au sport …découvrez la gamme de sports offerts par <span style="color: #65bb00;">NAME</span>.<br /><br /><br />
                NAME
            </div>
        </div>
    </div>

    <!--<div>
        <img class="logo-herbalife" src="images/herbalife.png" />
    </div>-->



    <footer class="blockquote-footer text-center">
        <div class="title-footer">
            <span style="color: #65bb00;">N</span>ame
        </div>
        <div class="text-footer">
            Street, 44 - 1000 Brussels<br />
            [email protected]<br />
            0111/11.11.11
        </div>
        <div>
            <ul>
                <li class="social-logo"><a href="#"><i class="fab fa-facebook-f fa-2x"></i></a></li>
                <li class="social-logo"><a href="#" class="nav-link"><i class="fab fa-instagram fa-2x"></i></a></li>
                <li class="social-logo"><a href="#" class="nav-link"><i class="far fa-envelope fa-2x"></i></a></li>
            </ul>
        </div>

    </footer>


</body>
</html>
html css
1个回答
0
投票
阅读CSS内部的评论

/*.footer { position: absolute; left: 0; bottom: 0; width: 100%; background-color: #24292e; color: rgba(255,255,255,0.75); text-align: center; }----------------------------------------------- You dont have this class on your code! */ * { box-sizing: border-box; } html { margin: 0; padding: 0; width: 100%; height: 100vh; } body { margin: 0; padding: 0; width: 100%; height: 100vh; font-family: Poppins; font-weight: 400; background: url(../images/background.jpg); background-position: center; background-size: cover; overflow-y: scroll; } nav { padding: 8px; } .logo { float: left; padding: 8px; margin-left: 16px; } .logo a { color: #ffffff; text-transform: uppercase; font-weight: 700; font-size: 22px; letter-spacing: 0px; text-decoration: none; } nav ul { float: right; } nav ul li { display: inline-block; float: left; } nav ul li:not(:first-child) { margin-left: 48px; } nav ul li:last-child { margin-right: 24px; } nav ul li a { display: inline-block; outline: none; color: #000; text-transform: uppercase; text-decoration: none; font-size: 14px; letter-spacing: 1.2px; font-weight: 600; } @media screen and (max-width: 864px) { .logo { padding: 0; } .nav-wrapper { position: fixed; top: 0px; left: 0; width: 100%; height: 100%; z-index: -1; background: #fff; opacity: 0; transition: all 0.2s ease; } .nav-wrapper ul { position: absolute; top: 50%; transform: translateY(-50%); width: 100%; } .nav-wrapper ul li { display: block; float: none; width: 100%; text-align: right; margin-bottom: 10px; } .nav-wrapper ul li:nth-child(1) a { transition-delay: 0.2s; } .nav-wrapper ul li:nth-child(2) a { transition-delay: 0.3s; } .nav-wrapper ul li:nth-child(3) a { transition-delay: 0.4s; } .nav-wrapper ul li:nth-child(4) a { transition-delay: 0.5s; } .nav-wrapper ul li:not(:first-child) { margin-left: 0; } .nav-wrapper ul li a { padding: 10px 24px; opacity: 0; color: #000; font-size: 14px; font-weight: 600; letter-spacing: 1.2px; transform: translateX(-20px); transition: all 0.2s ease; } .nav-btn { position: fixed; right: 10px; top: 10px; display: block; width: 48px; height: 48px; cursor: pointer; z-index: 9999; border-radius: 50%; } .nav-btn i { display: block; width: 20px; height: 2px; background: #ffffff; border-radius: 2px; margin-left: 14px; } .nav-btn i:nth-child(1) { margin-top: 16px; } .nav-btn i:nth-child(2) { margin-top: 4px; opacity: 1; } .nav-btn i:nth-child(3) { margin-top: 4px; } } #nav:checked + .nav-btn { transform: rotate(45deg); } #nav:checked + .nav-btn i { background: #000; transition: transform 0.2s ease; } #nav:checked + .nav-btn i:nth-child(1) { transform: translateY(6px) rotate(180deg); } #nav:checked + .nav-btn i:nth-child(2) { opacity: 0; } #nav:checked + .nav-btn i:nth-child(3) { transform: translateY(-6px) rotate(90deg); } #nav:checked ~ .nav-wrapper { z-index: 9990; opacity: 1; } #nav:checked ~ .nav-wrapper ul li a { opacity: 1; transform: translateX(0); } .hidden { display: none; } .txt { color:white; font-size:16px; } .container { margin-top: 1%; } .border-container { background-color: rgba(0, 0, 0, 0.7); margin-top: 7%; margin-bottom:1%; margin-left: 15%; margin-right: 15%; padding: 5px; border-radius: 5px; max-height: 690px; } .container-text { margin-top: 1%; margin-bottom: 1%; margin-left: 1%; margin-right: 1%; padding: 1%; border-radius: 3px; } .text { font-size: 14px; color: white; } .h1 { color: white; } .logo-herbalife { height: 50px; width: 50px; display: block; margin-left: auto; margin-right: auto; width: 5%; } .social-logo { list-style: none; padding-right: 30px; display: inline; margin-right:11px; } .fab { color: white; } .far { color: white; } * { margin: 0; } .active, .btn:hover { border-bottom: 2px solid #65bb00; } .blockquote-footer { background-color: rgba(0, 0, 0, 0.7); /*position: absolute; -------------------- If you want your footer remains at the button of your page */ left: 0; bottom: 0; width: 100%; text-align: center; padding: 5px 0 5px 0; clear: both; } .well { position: relative; } .title-footer { color: white; font-weight: 700; font-size: 22px; } .text-footer { margin: 0 0 12px 0; color: white; font-weight: 600; font-size: 11px; } .gallery { background-color: rgba(0, 0, 0, 0.7); margin-top: 7%; margin-bottom: 4%; margin-left: 15%; margin-right: 15%; padding: 10px; border-radius: 3px; text-align: center; } .gallery img{ transition: 0.7s; padding: 10px; width: 300px; height: 300px; } .gallery img:hover{ filter: grayscale(50%); transform: scale(1.1); } /*.ifooter { margin-bottom: -60px; } ------------------------------ You dont need any margins*/ .topnav a:hover { border-bottom: 5px solid #65bb00; padding-bottom: 8px; transition: all 0.3s linear; -webkit-transition: all 0.3s linear; -moz-transition: all 0.3s linear; } .topnav a.active { border-bottom: 5px solid #65bb00; padding-bottom:8px; }
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Accueil - Fab h24</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link href="https://fonts.googleapis.com/css?family=Poppins&display=swap" rel="stylesheet">
    <script src="https://kit.fontawesome.com/6d0f7aa58c.js" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>

<body class="body">
    <div class="container">
        <nav>
            <input type="checkbox" id="nav" class="hidden">
            <label for="nav" class="nav-btn">
                <i></i>
                <i></i>
                <i></i>
            </label>
            <div class="logo">
                <a href="index.html"><span style="color: #65bb00;">N</span>ame</a>
            </div>

            <div id="myDIV" class="nav-wrapper topnav">
                <ul>
                    <li><a href="index.html" class="txt active">Home</a></li>
                    <li><a href="coach.html" class="txt">Coaching</a></li>
                    <li><a href="programmes.html" class="txt">Produits</a></li>
                    <li><a href="galerie.html" class="txt">Galerie photos</a></li>
                    <li><a href="contact.html" class="txt">Contact</a></li>
                </ul>
            </div>
        </nav>
    </div>

    <div class="border-container">
        <div class="container-text">
            <h1 class="h1">Bienvenue chez <span style="color: #65bb00;">NAME</span> !</h1><br />
            <div class="text">
                Absorbés par le travail et la vie familiale, de nombreuses personnes éprouvent à l’heure actuelle des difficultés à trouver le temps et se motiver pour faire du sport.<br /><br />

                <span style="color: #65bb00;">NAME</span> vous accompagne pendant vos sessions de sport et vous aide à accomplir tous vos objectifs.<br /><br />

                Un programme complet et personnalisé mis au point par votre coach vous permet de travailler d’une façon précise et déterminée.<br /><br />

                Si vous souhaitez en savoir plus, n’hésitez pas à nous contacter.<br /><br />

                Cours individuels, cours collectifs, coaching d’entreprise, initiation au sport …découvrez la gamme de sports offerts par <span style="color: #65bb00;">NAME</span>.<br /><br /><br />
                NAME
            </div>
        </div>
    </div>

    <!--<div>
        <img class="logo-herbalife" src="images/herbalife.png" />
    </div>-->



    <footer class="blockquote-footer text-center ifooter" id="footer">
        <div class="title-footer">
            <span style="color: #65bb00;">N</span>ame
        </div>
        <div class="text-footer">
            Street, 44 - 1000 Brussels<br />
            [email protected]<br />
            0111/11.11.11
        </div>
        <div>
            <ul>
                <li class="social-logo"><a href="#"><i class="fab fa-facebook-f fa-2x"></i></a></li>
                <li class="social-logo"><a href="#" class="nav-link"><i class="fab fa-instagram fa-2x"></i></a></li>
                <li class="social-logo"><a href="#" class="nav-link"><i class="far fa-envelope fa-2x"></i></a></li>
            </ul>
        </div>

    </footer>


</body>
</html>
© www.soinside.com 2019 - 2024. All rights reserved.