页脚下的HTML / CSS空白

时间:2015-04-17 20:31:55

标签: html css ruby-on-rails sass

我在页脚下面有一个白色空间有问题。我已经在Stack Overflow上搜索过,似乎无法找到适合我的答案,所以希望有人可以帮我解决我的具体问题。

我注意到的事情:

  1. 我根本无法检查这个空白。我尝试使用开发工具检查所有内容,但它看起来不在HTML中。
  2. 这是一个Rails项目。我删除了<%= yield %>代码以查看它是否是来自其他网页/部分的空格,但在删除<%= yield %>代码后仍留有空格。
  3. 我没有使用任何Javascript文件
  4. application.html.erb

    <!DOCTYPE html>
    <html>
    <head>
      <title>DoINeedAJacket</title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
      <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
      <%= csrf_meta_tags %>
    </head>
    <body>
      <div class="wrapper">
        <%= yield %>
        <div class="push"></div>
      </div>
      <div class="footer">
        <ul>
          <%= link_to image_tag('facebook-1.png', size: '32x32'), '####' %>
          <%= link_to image_tag('twitter-1.png', size: '32x32'), '####' %>
          <%= link_to image_tag('linkedin-1.png', size: '32x32'), '####' %>
          <%= link_to image_tag('github-1.png', size: '32x32'), '####' %>
        </ul>
      </div>
    </body>
    </html>
    

    application.css.scss

    * {
      margin: 0;
    }
    
    html {
      height: 97%;
    }
    body {
      height: 100%;
    }
    
    .wrapper {
      min-height: 100%;
      height: auto !important;
      height: 100%;
      margin: 0 auto -3em;
    }
    
    .footer, .push {
      height: 3em;
      text-align: center;
      ul {
        padding: 0;
        margin-bottom: 0;
        img {
          margin: 0.5rem;
        }
      }
    }
    

    我将身高设置为97%的原因是因为我需要摆脱一些滚动空间。如果有更好的方法,请告诉我。

    谢谢!

2 个答案:

答案 0 :(得分:1)

position:relative;添加到.wrapper

position:absolute; bottom:0; 到你的footer

答案 1 :(得分:0)

这是页脚没有边距的CSS(没有SCSS,只有CSS):

    * {
      margin: 0;
    }
    html, body { margin: 0; padding: 0; }
    html {
      height: 97%;
    }
    body {
      height: 100%;
    }
    .wrapper {
      min-height: 100%;
      height: auto !important;
      height: 100%;
      margin: 0 auto -3em;
    }

    .footer, .push {
      height: 3em;
      text-align: center;
    }
    .footer {
      position: absolute;
      width: 100%;
      bottom: 0;
      padding-bottom: .5rem;
    }
    .footer  ul, .push  ul {
        padding: 0;
        margin-bottom: 0;
      }

    .footer  ul img, .push  ul img {
      margin: 0.5rem;
    }