Отрицательные нижние поля «нижний колонтитул» имеет раздражающую вертикальную полосу прокрутки, если задействован элемент <h> - PullRequest
0 голосов
/ 20 ноября 2018

У меня есть липкий нижний колонтитул, который реализован с помощью техники «Отрицательные нижние поля» (не использует flex, потому что нужно поддерживать IE)* в нем он рендерится с надоедливой вертикальной полосой прокрутки.

Мой временный обходной путь - вместо этого используйте <span>, но раскладка будет заметно отличаться.Какое лучшее решение здесь?

html,
body,
form {
  height: 100%;
  margin: 0;
}

.wrapper {
  min-height: 100%;
  /* Equal to height of footer */
  /* But also accounting for potential margin-bottom of last child */
  margin-bottom: -30px;
}

.footer,
.push {
  height: 30px;
}
<!DOCTYPE html>
<html>

<head>
  <title>Page Title</title>
</head>

<body>
  <form>
    <div class="wrapper">
      <h1>I am the header</h1><!--I needs to use span here-->
      <div class="push"></div>
    </div>
    <footer class="footer">
      <p>I am the footer</p><!--I needs to use span here-->
    </footer>
  </form>
</body>

</html>

Ответы [ 3 ]

0 голосов
/ 20 ноября 2018

Надеюсь, это поможет вам.

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
html, body,form {
/*height: 100%;*/
margin: 0;
font-weight:normal;
}
.wrapper {
width:90%;
margin:0 auto;
}
.footer{
position:absolute;
width:90%;
bottom:0;
left:5%;
right:5%;
}
.innerFooter{
display:block;
}
</style>
</head>
<body>
<form>
<div class="wrapper">
<h1>I am the header</span> //I needs to use span here</h1>
<div class="push"></div>
<div>
<p>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
</p>
</div>
</div>
<footer class="footer">
<div class="innerFooter">
<p>
<span>I am the footer</span>
<span>I needs to use span here</span>
</p> 
</div>

</footer>
</form>
</body>
</html>
0 голосов
/ 20 ноября 2018

Я создал JSFiddle с вашим кодом и исправлениями.Вот что я добавил:

.wrapper {
      padding: 1px 0;
      box-sizing: border-box;
}
 .footer,
 .push {
      height: 30px;
      overflow: hidden;
 }

https://jsfiddle.net/97hsqLav/

У вас было две основные проблемы:

  1. Проблема с полями была вызвана "Сжатием маржи",Как правило, начальные и конечные поля в некоторых случаях суммируются с родительскими.Установка отступа 1px решает эту проблему (установите его сверху и снизу, чтобы обеспечить оба пути).Требуется дополнительный box-sizing, поэтому высота остается 100% (вместо отступов 100% + 2 пикселя)
  2. Текст в нижнем колонтитуле был выше 30 пикселей, поэтому сам нижний колонтитул был на пару пикселей слишком высоким(таким образом вызывая полосу прокрутки).Overflow: hidden исправляет это, обрезая все, что превышает 30px
0 голосов
/ 20 ноября 2018
   .footer,   
      .push {
   height: 30px;
}

Это проблема, при которой высота нижнего колонтитула была ограничена 30 пикселями. Если вы вводите текст, длина которого превышает 30 пикселей, браузер автоматически прокрутит его, чтобы показать весь контент, попробуйте увеличить его до60px.

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