HTML定位:导航栏和文本之间的重叠

HTML定位:导航栏和文本之间的重叠,html,css,Html,Css,它是如此基本,但我似乎不能得到它的权利。导航栏位于导航栏下方后的正文文本的一部分。此外,当出现警告消息(例如错误的凭证)时,它会被放置在导航栏下方,因此无法读取。我做错了什么?(我正在使用Rails 3.2和Ruby 4) 在application.html.erb中,我有: <%= render "layouts/header" %> <% flash.each do |name,msg| %> <p class="alert"><%=

它是如此基本,但我似乎不能得到它的权利。导航栏位于导航栏下方后的正文文本的一部分。此外,当出现警告消息(例如错误的凭证)时,它会被放置在导航栏下方,因此无法读取。我做错了什么?(我正在使用Rails 3.2和Ruby 4)

在application.html.erb中,我有:

  <%= render "layouts/header" %>
  <% flash.each do |name,msg| %>
    <p class="alert"><%= content_tag :div, msg, :id => name %></p>
  <% end %>
  <p class="notice"><%= notice %></p>
  <%= yield %>
  <%= render "layouts/footer" %>
-文本的CSS:

/* JUMBOTRON ON HOME
================================================== */
.jumbotron {
  background-image: url('http://www.....com/....jpg');
  height: 500px;
  background-repeat: no-repeat;
  background-size: cover;
}

.jumbotron h1 {
  color: #fff;
  font-size: 48px;  
  font-family: 'Shift', sans-serif;
  font-weight: bold;
}

.jumbotron p {
  font-size: 20px;
  color: #fff;
}


/* CUSTOMIZE THE CAROUSEL
================================================== */
/* Carousel base class */
.carousel {
  height: 500px;
  margin-bottom: 60px;
}
/* Since positioning the image, we need to help out the caption */
.carousel-caption {
  z-index: 10;
}

/* Declare heights because of positioning of img element */
.carousel .item {
  height: 500px;
  background-color: #777;
}
.carousel-inner > .item > img {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  height: 500px;
}


/* ILLUSTRATIES
================================================== */
.illustraties{
    background-color: #efefef;
    border-bottom: 1px solid #dbdbdb;
}

.learn-more {
  background-color: #f7f7f7;
}

.learn-more h3 {
  font-family: 'Shift', sans-serif;
  font-size: 18px;
  font-weight: bold;
}

.learn-more a {
  color: #00b0ff;
}

您的导航栏是固定的,这意味着它位于所有内容之上,但具有较高z索引的内容具有绝对或固定位置

只要在你的身体上加上一个边距,就像导航栏的高度一样。
你的所有内容都应该放在导航栏下面

您的导航栏是固定的,这意味着它位于所有内容之上,除了具有较高z索引的内容具有绝对或固定位置

只要在你的身体上加上一个边距,就像导航栏的高度一样。
你的所有内容都应该放在导航栏下面

如果将其设置为绝对。您可能需要提供100%的宽度 我基本上把整个导航移到了header标签,定义如下

header{
    position: absolute;
    z-index:2;
    width: 100%;
}

如果将其设置为绝对值。您可能需要提供100%的宽度 我基本上把整个导航移到了header标签,定义如下

header{
    position: absolute;
    z-index:2;
    width: 100%;
}

谢谢,我添加了CSSThanks,我添加了CSSThanks,我将body{margin top:20px;}添加到CSS中,修复了它。谢谢,我将body{margin top:20px;}添加到CSS中,修复了它。
header{
    position: absolute;
    z-index:2;
    width: 100%;
}