Как сделать так, чтобы мой нижний колонтитул оставался в нижней части моей страницы в CSS без наложения - PullRequest
0 голосов
/ 28 февраля 2019

Привет, я новичок в изучении HTML / CSS, в настоящее время я пытаюсь понять, почему мой нижний колонтитул перекрывает мою веб-страницу, я пытался использовать postion: fixed;& bottom: 0;чтобы держать это в нижней части, но это не работает, ответ, вероятно, очевиден для кого-то, я буду признателен за любую помощь по этому вопросу, см. мой HTML / CSS код ниже.

Изображение веб-страницы> https://imgur.com/a/GT02Ggx

HTML

<body>
    <section class="slider">
        <ul class="slider-carousel" id="slider-carousel">

            <li class="img1">
                <h2>Slider<span>Slider</span></h2>
                <p>Hello World</p>
                <i class="fab fa-apple"></i>
                <i class="fab fa-android"></i>
                <i class="fab fa-windows"></i>
                <p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
                </p><br>
                <a href="" class="btn btn-half">Get Started</a>
                <a href="" class="btn btn-full">Lets Go</a>
            </li>


            <li class="img2">
                <h2>Slider<span>Slider</span></h2>
                <p>Hello World</p>
                <i class="fab fa-apple"></i>
                <i class="fab fa-android"></i>
                <i class="fab fa-windows"></i>
                <p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
                </p><br>
                <a href="" class="btn btn-half">Get Started</a>
                <a href="" class="btn btn-full">Lets Go</a>
            </li>


            <li class="img3">
                <h2>Slider<span>Slider</span></h2>
                <p>Hello World</p>
                <i class="fab fa-apple"></i>
                <i class="fab fa-android"></i>
                <i class="fab fa-windows"></i>
                <p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
                </p><br>
                <a href="" class="btn btn-half">Get Started</a>
                <a href="" class="btn btn-full">Lets Go</a>
            </li>

        </ul>



    <div class="login-box">
            <h1>Login</h1>

            <div class="textbox">
                <i class="fas fa-user"></i>
                <input type="text" placeholder="Username" name="" value="">
            </div>


       <div class="textbox">
           <i class="fas fa-lock"></i>
                <input type="text" placeholder="Password" name="" value="">
            </div>

            <input class="btn" type="button" name="" value="Sign In">


             </div>
    </section>


    <footer>
        <div class="wrapper">
            <nav>
                <ul>
                    <li><a href="">Log In</a></li>
                    <li><a href="">FAQ</a></li>
                    <li><a href="">My Surveys</a></li>
                </ul>
            </nav>
        </div>
     <script src="main.js"></script>

</body>

CSS

  }

body{
    height:100%;
    background-color:black !important;
}

/*-------------header-----------*/


header
{
    height:110px;
    line-height: 110px;
    position:fixed;
    z-index:1;
    width:100%;
}

.secondary{
    background-color:darkorange;
    box-shadow:0px 0px 15px 0px;
    transition:all 0.5s ease-in-out;
}

/*-------------nav-----------*/


ul
{
    list-style:none;

}

ul li
{
    display:inline-block;

}

header nav
{
    float: right;
}

.logo img
{
    margin-top:25px;
}

header nav ul li a 
{
    padding-right: 25px;
    font-weight: bold;
    color: white;
    transition: all 0.5s ease-in;
}

header nav ul li a:hover
{
    text-decoration: none;
    color:black;
}

/*-------------slider-----------*/


.img1
{
    background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work.jpg);
    background-size:100% 100%;


}

.slider,.slider ul,.slider ul li
{
    height:700px;
    width:100%;
    color:white;
    text-align: center;
    padding:0px;

}

.slider h2
{
    font-weight: bold;
    margin-top:260px;
}

.slider span
{
    color:orange;
}

.slider a 
{
    padding: 10px 40px;
    margin-right: 10px;

}

.slider a.btn-half

{
    background-color: orange;
    color: white;
}

.slider a.btn-half:hover
{
    opacity:0.7;
    transition:0.5s ease-in;
}

.slider a.btn-full
{
    background-color: black;
    color: white;
}

.slider a.btn-full:hover
{
    opacity:0.7;
    transition:0.5s ease-in;

}

.img2
{
    background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work2.jpg);
    background-size:100% 100%;
}

.img3
{
    background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work3.jpg);
    background-size:100% 100%;
}

.slider i
{
    font-size:30px;
    margin-right:10px;
}

/*-------------login-----------*/



.login-box
{
    width:280px;
    position:absolute;
    top:1000px;
    left:50%;
    transform: translate(-50%, -50%);
    color:white;
}

.login-box h1 
{
    width:100px;
    font-size:40px;
    border-bottom: 6px solid darkorange;
    margin-bottom:50px;
    padding:13 px 0;
}

.textbox
{
    width:100%;
    overflow:hidden;
    font-size:20px;
    padding:8px 0;
    margin:8px 0;
    border-bottom: 1px solid darkorange;
}

.textbox i 
{
    width:26px;
    float:left;
    text-align:center;
}

.textbox input
{
    border:none;
    outline:none;
    background:none;
    color:white;
    font-size:17px;
    width:80%;
    float:left;
    margin:0 10px;
}

.btn
{
    width:100%;
    background:none;
    border:2px solid darkorange;
    color:white;
    padding:5px;
    font-size:17px;
    cursor:pointer;
    margin:12px 0;
}

.btn:hover
{
    opacity:0.7;
    transition:0.5s ease-in;
}

/*-------------footer-----------*/


.footer {
   width:100%;
    background-color: darkorange;
    padding:50px 0px;
    position:fixed;

}



footer nav
{
    text-align:center;
}


footer nav ul li a 
{
    padding-right: 25px;
    font-weight: bold;
    color: white;
    transition: all 0.5s ease-in;
}

footer nav ul li a:hover
{
    text-decoration: none;
    color:black;
}

Ответы [ 2 ]

0 голосов
/ 28 февраля 2019

Проблема в вашем CSS за пределами footer.В селекторе .slider, .slider ul, .slider ul li у вас есть height: 700px;.Поскольку у вас есть 3 из этих элементов, он по существу растягивается 2100 px! Поскольку у вас footer установлено значение position: fixed;, оно хочет остаться в этой позиции на экране, даже если оно уже есть.содержание там.

Вот как должны выглядеть эти 2 селектора:

.slider, .slider ul, .slider ul li{
    width:100%;
    color:white;
    text-align: center;
    padding:0px;
}
footer {
    width:100%;
    background-color: darkorange;
    padding:50px 0px;
}

body{
    height:100%;
    background-color:black !important;
}

/*-------------header-----------*/


header
{
    height:110px;
    line-height: 110px;
    position:fixed;
    z-index:1;
    width:100%;
}

.secondary{
    background-color:darkorange;
    box-shadow:0px 0px 15px 0px;
    transition:all 0.5s ease-in-out;
}

/*-------------nav-----------*/


ul
{
    list-style:none;

}

ul li
{
    display:inline-block;

}

header nav
{
    float: right;
}

.logo img
{
    margin-top:25px;
}

header nav ul li a 
{
    padding-right: 25px;
    font-weight: bold;
    color: white;
    transition: all 0.5s ease-in;
}

header nav ul li a:hover
{
    text-decoration: none;
    color:black;
}

/*-------------slider-----------*/


.img1
{
    background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work.jpg);
    background-size:100% 100%;


}

.slider, .slider ul, .slider ul li{
    width:100%;
    color:white;
    text-align: center;
    padding:0px;
}

.slider h2
{
    font-weight: bold;
    margin-top:260px;
}

.slider span
{
    color:orange;
}

.slider a 
{
    padding: 10px 40px;
    margin-right: 10px;

}

.slider a.btn-half

{
    background-color: orange;
    color: white;
}

.slider a.btn-half:hover
{
    opacity:0.7;
    transition:0.5s ease-in;
}

.slider a.btn-full
{
    background-color: black;
    color: white;
}

.slider a.btn-full:hover
{
    opacity:0.7;
    transition:0.5s ease-in;

}

.img2
{
    background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work2.jpg);
    background-size:100% 100%;
}

.img3
{
    background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work3.jpg);
    background-size:100% 100%;
}

.slider i
{
    font-size:30px;
    margin-right:10px;
}

/*-------------login-----------*/



.login-box
{
    width:280px;
    position:absolute;
    top:1000px;
    left:50%;
    transform: translate(-50%, -50%);
    color:white;
}

.login-box h1 
{
    width:100px;
    font-size:40px;
    border-bottom: 6px solid darkorange;
    margin-bottom:50px;
    padding:13 px 0;
}

.textbox
{
    width:100%;
    overflow:hidden;
    font-size:20px;
    padding:8px 0;
    margin:8px 0;
    border-bottom: 1px solid darkorange;
}

.textbox i 
{
    width:26px;
    float:left;
    text-align:center;
}

.textbox input
{
    border:none;
    outline:none;
    background:none;
    color:white;
    font-size:17px;
    width:80%;
    float:left;
    margin:0 10px;
}

.btn
{
    width:100%;
    background:none;
    border:2px solid darkorange;
    color:white;
    padding:5px;
    font-size:17px;
    cursor:pointer;
    margin:12px 0;
}

.btn:hover
{
    opacity:0.7;
    transition:0.5s ease-in;
}

/*-------------footer-----------*/


footer {
    width:100%;
    background-color: darkorange;
    padding:50px 0px;
}



footer nav
{
    text-align:center;
}


footer nav ul li a 
{
    padding-right: 25px;
    font-weight: bold;
    color: white;
    transition: all 0.5s ease-in;
}

footer nav ul li a:hover
{
    text-decoration: none;
    color:black;
}
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
    <section class="slider">
        <ul class="slider-carousel" id="slider-carousel">
            <li class="img1">
                <h2>Slider<span>Slider</span></h2>
                <p>Hello World</p>
                <i class="fab fa-apple"></i>
                <i class="fab fa-android"></i>
                <i class="fab fa-windows"></i>
                <p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
                </p><br>
                <a href="" class="btn btn-half">Get Started</a>
                <a href="" class="btn btn-full">Lets Go</a>
            </li>
            <li class="img2">
                <h2>Slider<span>Slider</span></h2>
                <p>Hello World</p>
                <i class="fab fa-apple"></i>
                <i class="fab fa-android"></i>
                <i class="fab fa-windows"></i>
                <p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
                </p><br>
                <a href="" class="btn btn-half">Get Started</a>
                <a href="" class="btn btn-full">Lets Go</a>
            </li>
            <li class="img3">
                <h2>Slider<span>Slider</span></h2>
                <p>Hello World</p>
                <i class="fab fa-apple"></i>
                <i class="fab fa-android"></i>
                <i class="fab fa-windows"></i>
                <p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
                </p><br>
                <a href="" class="btn btn-half">Get Started</a>
                <a href="" class="btn btn-full">Lets Go</a>
            </li>
        </ul>
        <div class="login-box">
            <h1>Login</h1>
            <div class="textbox">
                <i class="fas fa-user"></i>
                <input type="text" placeholder="Username" name="" value="">
            </div>
            <div class="textbox">
                <i class="fas fa-lock"></i>
                <input type="text" placeholder="Password" name="" value="">
            </div>
            <input class="btn" type="button" name="" value="Sign In">
        </div>
    </section>
    <footer>
        <div class="wrapper">
            <nav>
                <ul>
                    <li><a href="">Log In</a></li>
                    <li><a href="">FAQ</a></li>
                    <li><a href="">My Surveys</a></li>
                </ul>
            </nav>
        </div>
    </footer>
    <script src="main.js"></script>
</body>
</html>
0 голосов
/ 28 февраля 2019

Первый , у вашего нижнего колонтитула нет конечного тега, например </footer>

Второй , добавьте класс в нижний колонтитул как footer class = "footer" или, может быть, обернуть все это в div class = "footer" , затем добавить. (Точку) перед нижним колонтитулом в css, как .footer {//something here} Затем добавьте свойство clear: both к тому, что выиметь в вашем css.

.footer {
    width:100%;
    background-color: darkorange;
    padding:50px 0px;
    position:fixed;
    clear: both; // like this
}

Свойство clear сообщает, на каких сторонах элемента плавающие элементы не могут плавать.

Используя оба значения для очистки.Вы можете указать, что ни один элемент не может плавать ни на правой, ни на левой стороне элемента.

На всякий случай: при попытке очистки: оба.Если это не сработало, измените положение на относительное.

...