Bootstrap菜单推送另一个div

时间:2017-07-30 17:29:37

标签: javascript jquery html css twitter-bootstrap

我有这个问题,我的Bootstrap菜单将另一个名为“title”的div推下来(在手机上,xs)到目前为止链接到网站:http://20162.hosts.ma-cloud.nl/portfoliowebsite

我真的不知道我现在应该做什么,因为我希望菜单下降,但div“title”留在原位。

HTML:

    <!DOCTYPE html>
<html lang="en">

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta charset="UTF-8">
  <meta name="author" content="Daniel Gotz">
  <title>Daniel Gotz | Porfolio </title>
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/styles.css" rel="stylesheet">
  <link href="css/scrolling-nav.css" rel="stylesheet">
  <link href="dist/hamburgers.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Exo+2:600,900|Roboto" rel="stylesheet">
 </head>

<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">

  <!-- Navigation -->

  <section id="intro" class="intro-section">
        <nav class="navbar navbar-default" role="navigation">
        <div class="navbar-header page-scroll">
          <button class=" hamburger hamburger--spin navbar-toggle visible-xs" type="button" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class=" hamburger-box">
    <span class=" hamburger-inner"></span> </span>
          </button>
        </div>
        <div class="collapse navbar-collapse navbar-ex1-collapse">
          <ul class="nav navbar-nav right">
            <li class="hidden">
              <a class="page-scroll" href="#page-top"></a>
            </li>
            <li> <a class="page-scroll" href="#intro">Intro</a> </li>
            <li> <a class="page-scroll" href="#mijnwerk">Mijn werk</a> </li>
            <li> <a class="page-scroll" href="#overdaniel">Over Daniel</a> </li>
            <li> <a class="page-scroll" href="#contact">Contact</a> </li>
          </ul>
      </div>
    </nav>
       <div class="title">
      <h1> Every mountain top is within reach if you just keep climbing</h1> </div>

      <div class="berg">
    <img src="berg.svg">


      </div>


  </section>
  <section id="mijnwerk" class="about-section"> </section>
  <section id="overdaniel" class="services-section"> </section>
  <section id="contact" class="contact-section"> </section>
  <!-- jQuery -->
  <script src="js/jquery.js"></script>
  <!-- Bootstrap Core JavaScript -->
  <script src="js/bootstrap.min.js"></script>
  <!-- Scrolling Nav JavaScript -->
  <script src="js/jquery.easing.min.js"></script>
  <script src="js/scrolling-nav.js"></script>
  <script src="js/hamburgers.js"></script>
</body>

</html>

CSS:

    .overflow {
  overflow-x: hidden;
  position: relative;
}

.home {
  height: 100vh;
  width: 100vw;
  background-color: #2ecc71;
}

.mijnwerk {
  height: 100vh;
  width: 100vw;
  background-color: #27ae60;
}


.navbar-default {
  background: none;
  border-style: none;
}

.right {
  float: right;
  text-align: right;

}

.navbar-default .navbar-nav>li>a {
  font-family: 'Roboto', sans-serif;
  color: #ecf0f1;
  font-size: 14px;


}

.nav>li>a {
  padding: 15px 25px;
    border-style: none;



}

.navbar-default .navbar-nav>li>a:focus,
.navbar-default .navbar-nav>li>a:hover {
  color: #ecf0f1;
      border-style: none;

}

.navbar-default .navbar-toggle:focus,
.navbar-default .navbar-toggle:hover {
  background: none


}

.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
  border-style: none;



}



h1 {

  font-family:  'Exo 2' , sans-serif;
  font-weight: 900;
  font-size: 37px;
  line-height: 60px;


}

.title {
  z-index: 2;
  font-family:  'Exo 2' , sans-serif;
  margin-left: auto;
  margin-right: auto;
  vertical-align: center;
  text-align: center;
  width: 350px;
    position: relative;
  top: 35%;
  transform: translateY(-50%);

}

.berg {
    position: absolute;
    width: 100%;
    bottom: 0;
    margin: 0  0 -2px 0;

body {
    width: 100%;
    height: 100%;
}

html {
    width: 100%;
    height: 100%;
}

@media(min-width:767px) {
    .navbar {

    }

    .top-nav-collapse {
        padding: 0;
    }
}

.intro-section {
    height: 100%;
    background: #2ecc71;
    color: white;
  text-align: center;


}

.about-section {
    height: 100%;
    background: #27ae60;
}

.services-section {
    height: 100%;
    background: #3498db;
}

.contact-section {
    height: 100%;
    padding-top: 150px;
    text-align: center;
    background: #eee;
}

2 个答案:

答案 0 :(得分:0)

尝试绝对定位您的.title div。

.title {
  font-family: 'Exo 2', sans-serif;
  text-align: center;
  width: 350px;
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
}

答案 1 :(得分:0)

由于Navbar应始终位于同一位置,因此将导航栏绝对定位似乎最简单。创建一个新类并添加它,或者补充.navbar-default

.navbar-default {
    position: absolute;
    right: 0;
}
相关问题