【问题标题】:Rails - HTML page won't take full heightRails - HTML 页面不会占满高度
【发布时间】:2016-03-03 19:31:21
【问题描述】:

我正在按照一个教程尝试创建一个管理面板,但我在某个时候卡住了。我正在尝试使导航栏+文本占据全高,但它们有点“包装内容”。

这是我的html:

<!DOCTYPE html>
<html>
<head>
  <title>TEAM 21 </title>
  <%= stylesheet_link_tag 'adminpanel', media: 'all', 'data-turbolinks-track' => true %>
  <!-- <%= javascript_include_tag 'adminpanel', 'data-turbolinks-track' => true %> -->
  <%= csrf_meta_tags %>
</head>
<body>
  <%if flash[:notice] %>
    <div class="notice"><%= flash[:notice] %></div>
  <% end %>

  <%if flash[:alert] %>
    <div class="alert"><%= flash[:alert] %></div>
  <% end %>

  <!-- HEADER
  ================================================== -->
  <div class="containter-fluid display-table">
        <div class="row display-table-row">
          <!-- Side menu -->
          <div class="col-md-2 display-table-cell valign-top" id="side-menu">
            <h1> Navigation </h1>

          </div>

          <!-- Main content area -->
          <div class="col-md-10 box display-table-cell valign-top">

            <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry.
               Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with
               the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
            </p>

            <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry.
               Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with
               the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
            </p>
          </div>
        </div>
    </div>

    <!-- CONTENT
    ================================================== -->
    <div class="buffer-top">
      <!-- <%= yield %> -->
    </div>


   <!-- Bootstrap core JavaScript
   ================================================== -->
   <!-- Placed at the end of the document so the pages load faster -->
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
   <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>

 </body>
</html>

这是我的 CSS:

    @import "bootstrap-sprockets"
@import "bootstrap"


html body
  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif
  background-color: #f3f3f4
  color: #676a6c
  height: 100%



.box
  border: 1px red dotted


#side-menu
  background-color: #2f4050
  padding: 0px

#side-menu h1
  color: #1f3647
  text-align: center
  margin: 10px 0px
  font-size: 25px

.display-table
  display: table
  padding: 0px
  height: 100%

.display-table-row
  display: table-row
  height: 100%

.display-table-cell
  display: table-cell
  height: 100%
  float: none

.valign-top
  vertical-align: top

编辑:我忘了提。我已经尝试了所有我能找到的解决方案,但它不会完全发挥作用。

【问题讨论】:

    标签: html css ruby-on-rails twitter-bootstrap


    【解决方案1】:

    这不是 CSS。我假设这是sass?检查身体边缘。通常是10px。否则,您的 html 也将达到 100% 的高度

    html
      height: 100%
    

    【讨论】:

    • 当你只有body 作为100% 并且html0px 高时,那么body 是0px100%,因此仍然是0px。所以通常记得设置html高度:)
    • 我有这样的,但他们在同一行
    • 啊,好吧,我明白了
    猜你喜欢
    • 2014-04-21
    • 1970-01-01
    • 1970-01-01
    • 2021-07-17
    • 2017-07-14
    • 2020-10-30
    • 2020-02-16
    • 2016-02-18
    • 1970-01-01
    相关资源
    最近更新 更多