【问题标题】:When I jump from one page to the next on my site it exposes the HTML in Chrome当我在我的网站上从一个页面跳转到下一个页面时,它会在 Chrome 中公开 HTML
【发布时间】:2016-05-22 00:31:10
【问题描述】:

我的网站中有类别。当我从一个类别转到下一个类别时,HTML 会在一瞬间暴露。仅供参考,我正在使用 Chrome。

<!DOCTYPE html>
<html></html>
<head>
<title>Dating Catalog</title>
<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
  <nav class="navbar navbar-default">
  <div class="container">
    <%= link_to "Dating Catalog", root_path, class: "navbar-brand" %>
      <ul class="nav navbar-nav">
        <!-- lists and links all categories on the top of home page -->
        <% Category.all.each do |category| %>
        <li class="category-link">
      <%= link_to category.name, resources_path(category: category.name) %>
      </li>
    <% end %>
  </ul>
</div>
</nav>
<div class="container">
<div class="col-md-6 col-md-offset-3">
 <%= yield %>
</div>

【问题讨论】:

  • 确保在 yield 块之后有一个容器 div 的结束 div 标签。
  • 你有 '

标签: html css ruby-on-rails ruby-on-rails-4


【解决方案1】:

请确保:

  • &lt;body&gt;&lt;div&gt; 等 HTML 标记用 &lt;/body&gt;&lt;/div&gt; 正确关闭。
  • &lt;head&gt;...&lt;/head&gt;&lt;body&gt;...&lt;/body&gt; 包裹在 &lt;html&gt;...&lt;/html&gt; 内。

例如:

<!DOCTYPE html>
<html>
  <head>
    <!-- ... -->
  </head>
  <body>
    <nav class="navbar navbar-default">
      <!-- ... -->
    </nav>
    <div class="container">
      <div class="col-md-6 col-md-offset-3">
        <%= yield %>
      </div>
    </div>
  </body>
</html>

【讨论】:

    猜你喜欢
    • 2021-04-15
    • 1970-01-01
    • 2020-11-19
    • 2021-08-17
    • 2019-09-16
    • 2021-07-30
    • 1970-01-01
    • 1970-01-01
    • 2016-12-07
    相关资源
    最近更新 更多