Одна html дивизия укладывается поверх другой - PullRequest
0 голосов
/ 01 мая 2020

Я делаю небольшую веб-страницу, которая показана ниже. В конце есть нижний колонтитул, над которым написано «Сделано с любовью Випул Тяги». Проблема в том, что он подходит к предыдущему разделу (форма обратной связи). Независимо от того, какое свойство top я применяю к нижнему колонтитулу, оно не сдвигается ни капли.

Пожалуйста, посмотрите на мой код и помогите мне найти проблему. Вы найдете его в самом конце в html чуть выше тега </body>.

Заранее спасибо!

$(document).ready(function() {
  $("#notif-list li").click(function(e) {
    var num = parseInt($("#notif-number").text());
    $(this).remove();
    $("#notif-number").html("" + num - 1 + "");
  });
});
.container1 {
  position: relative;
  color: white;
}

.centered {
  position: absolute;
  top: 70%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
}

.fa-input {
  font-family: FontAwesome, 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.top-left {
  position: absolute;
  top: 30%;
  left: 55%;
  transform: translate(-50%, -50%);
}

.heading {
  font-family: 'Orbitron', serif;
}

#headmain {
  font-size: 50px;
  position: relative;
  left: -55px;
  color: white;
}

#headsecondary {
  position: relative;
  right: 5%;
  color: white;
}

#top-content {
  position: relative;
  top: 40px;
  width: 100%;
  background-color: #bbb;
  padding: 10px;
}

a {
  color: white;
}

.number {
  position: absolute;
  top: -5px;
  right: -2px;
  padding: 5px 10px;
  border-radius: 30%;
  background: green;
  color: white;
}

.borderimg {
  border-radius: 30%;
}

.carosel {
  width: 670px;
}

.service-list {
  font-family: 'Lobster', cursive;
  font-size: 50px;
}

.labels {
  font-size: 15px;
}

.login-box {
  width: 320px;
  height: 520px;
  top: 290px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  box-sizing: border-box;
  padding: 70px 30px;
}

.login-box p {
  margin: 0;
  padding: 0;
  font-weight: bold;
}

.login-box input {
  width: 100%;
  margin-bottom: 20px;
}

.login-box input[type="text"],
input[type="password"] {
  border: none;
  border-bottom: 1px solid #fff;
  background: transparent;
  outline: none;
  height: 40px;
  color: #fff;
  font-size: 16px;
}

.login-box input[type="submit"] {
  border: none;
  outline: none;
  height: 40px;
  background: #1c8adb;
  color: #fff;
  font-size: 18px;
  border-radius: 20px;
}

.login-box input[type="submit"]:hover {
  cursor: pointer;
  background: #39dc79;
  color: #000;
}

.login-box a {
  text-decoration: none;
  font-size: 14px;
  color: #fff;
}

.login-box a:hover {
  color: #39dc79;
}

@media screen and (max-width: 450px) {
  .carosel {
    width: 300px;
  }
  .top-left {
    position: absolute;
    top: 35%;
    left: 55%;
    transform: translate(-50%, -50%);
  }
  #headmain {
    font-size: 30px;
    position: relative;
    left: -20px;
    color: white;
  }
  #headsecondary {
    font-size: 20px;
    position: relative;
    right: 5%;
    color: white;
  }
  #service-list {
    font-family: 'Lobster', cursive;
    font-size: 30px;
  }
  .login-box {
    width: 300px;
    height: 500px;
    position: relative;
    top: 50px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    box-sizing: border-box;
    padding: 70px 30px;
  }
}
image

РЕДАКТИРОВАТЬ Хотя я нашел решение, но я все еще не понимаю, в чем проблема? Я никогда не видел такого поведения с top prperty!

Ответы [ 2 ]

1 голос
/ 01 мая 2020

Оберните нижний колонтитул вокруг тега нижнего колонтитула и используйте этот тег, чтобы отрегулировать положение на своей странице. css, который я использовал:

  margin-top: 50%;

Я также добавил для вас скрипку js. Взгляните на эту ссылку: https://jsfiddle.net/zfhassaan/5syxnme1/1/

0 голосов
/ 01 мая 2020

В стиле class = "нижний колонтитул контейнера", вы использовали положение как относительное. Таким образом, вы можете добавить top: несколько пикселей (например, top: 200px) к вашему стилю, чтобы держать нижний колонтитул там, где вы хотите. Для справки: https://www.w3schools.com/css/css_positioning.asp

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...