【问题标题】:Responsive CSS with Twitter Bootstrap使用 Twitter Bootstrap 的响应式 CSS
【发布时间】:2013-08-19 19:23:10
【问题描述】:

在我的 Rails 应用程序中,我使用的是 Twitter Bootstrap。我的页脚在具有足够宽度的横向模式的屏幕上正确显示。
下面是它的外观:

但是,在我的 Android Galaxy Note 上的浏览​​器上,它似乎坏了。如果我在横向模式下使用浏览器,页脚看起来是正确的,但在纵向模式下它会中断。它看起来像:

这是我的代码:

<div id="footer">
  <div class="container">
    <p class="muted credit" style="text-align: center" >

        &copy; 2013 <a href="http://www.example.com">WebsiteName.com</a> All Rights Reserved.   |   
        <a href="" title="Privacy Policy">Privacy Policy</a>   |     
        <%= link_to 'Terms of Service', terms_of_service_path %>

    </p>
  </div>
</div>

上面的CSS是从Example - sticky-footer 借来的:

  html,
  body {
    height: 100%;
    /* The html and body elements cannot have any padding or margin. */
  }

  /* Wrapper for page content to push down footer */
  #wrap {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    width: 100%;
    /* Negative indent footer by it's height */
    margin: 0 auto -60px;
    position: fixed;
    left:0;
    top:0;
  }

  /* Set the fixed height of the footer here */
  #push,
  #footer {
    height: 60px;
  }
  #footer {
    background-color: #f5f5f5;
  }

  /* Lastly, apply responsive CSS fixes as necessary */
  @media (max-width: 767px) {
    #footer {
      margin-left: -20px;
      margin-right: -20px;
      padding-left: 20px;
      padding-right: 20px;
    }
  }

  .container .credit {
    margin: 20px 0;
  }

我不知道为什么它不能正确渲染。我是响应式 CSS 的新手,我正在学习。请让我知道出了什么问题。

【问题讨论】:

  • 您的页脚似乎不适合您笔记上的可用空间。那么,您希望您的设计如何应对较小的空间?
  • @KatieK:我希望将隐私政策和服务条款显示在版权下方的另一行。
  • 投反对票的原因???

标签: css ruby-on-rails twitter-bootstrap responsive-design


【解决方案1】:

它呈现完全正常。没有足够的空间让内容放在一行中,所以它会放在新的一行。如果您不希望您的链接像这样在两行中分开并且始终适合一行,请尝试:white-space: nowrap; 在锚标记上,全局或您选择的分辨率。

【讨论】:

  • 我也尝试增加页脚的高度,但没有成功。我尝试更改#footer 高度并相应地将#wrap 边距值设置为负值。但是,它没有用。我不知道如何解决这个问题,我只是在 Bootstrap 上使用了上述示例。
  • 您也可以尝试将版权文本放在一个 div 中,将链接放在另一个 div 中。在更大的分辨率上,您将它们设为display: inline;,在更小的display: block; 上。这样,无论宽度如何,它们都将始终位于不同的行上。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-12
  • 1970-01-01
  • 2012-08-02
  • 2014-06-29
相关资源
最近更新 更多