内容部分超过标题

时间:2013-11-16 03:20:02

标签: html css twitter-bootstrap background background-image

我想制作类似于http://www.thomaspomarelle.com/(当然是自定义设计)的东西,但我遇到的问题是我的关于应该在背景图片下面并通过滚动页面访问的部分,在标题的顶部:(我绝对无法弄清楚为什么。我在想这是因为我在身体中有图像,但我尝试将图像放在标题部分之后的div中,并且它没有'干活了。 这是我的代码:

<html>
  <head>
    <title>yudasinal</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet" media="screen">
    <link rel="stylesheet" type="text/css" href="custom.css">
   </head>

 <body id="backimage">
    <nav class="navbar-wrapper navbar-default navbar-fixed-top" role="navigation">
        <div class="container">
          <div class="navbar-header">
            <a class="navbar-brand" href="#">LOGO</a>
          </div>
          <div id = "projects">
            <ul>
              <li class = "line">
                <a href = "#">HOME</a>
              </li>
              <li class = "line">
                <a href = "#">HOME</a>
              </li>
              <li class = "line">
                <a href = "#">HOME</a>
              </li>
            </ul>
    </nav>  

    <script src="//code.jquery.com/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

这里是css:

#projects ul {
    text-align: right;
    margin-right: 10px;
    padding: 15px 15px;
    font-size: 18px;
    line-height: 60px;
}

#projects li {
    display: inline-block;
    height: 40px;
    position: relative;
    overflow: hidden;
    background-position: top center; 
}

#projects ul li.line a {
    padding: 0 30px 30px;
    text-align: center;
}

#projects li.line a::after {
    position: absolute;
    top: 87%;
    left: 0;
    width: 100%;
    height: 3px;
    background: black;
    content: '';
    opacity: 0;
    -webkit-transition: height 0.3s, opacity 0.3s, -webkit-transform 0.3s;
    -moz-transition: height 0.3s, opacity 0.3s, -moz-transform 0.3s;
    transition: height 0.3s, opacity 0.3s, transform 0.3s;
    -webkit-transform: translateY(-10px);
    -moz-transform: translateY(-10px);
    transform: translateY(-10px);
}

#projects li.line a:hover::after,
#projects li.line  a:focus::after {
    height: 5px;
    opacity: 1;
    -webkit-transform: translateY(0px);
    -moz-transform: translateY(0px);
    transform: translateY(0px);
}


#backimage {
    background-image: url(http://cs425729.vk.me/v425729136/4e67/6abwVXLTK9s.jpg);
    background-repeat: no-repeat;
    background-position: center center;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    width: 100%;
    height: auto;
}

.wrapper {
  width: 1000px;
  margin: auto;
  clear: both;
  z-index: 10;
}

它还有twitter bootstrap css。

非常感谢你提前帮助!!!

1 个答案:

答案 0 :(得分:1)

我一直试图获得同样的效果。我发现html,body和保存背景图像的div需要100%的高度。我发现这样做的最好方法。如果有人有更好的方法,请分享。

小提琴:http://jsfiddle.net/b87pV/

HTML

 <body>
 <div class="first">
     <div class="header">
         <div class="logo">LOGO</div>
         <nav>
             <ul>
               <li><a href="#">link</a></li> 
               <li><a href="#">link</a></li>
               <li><a href="#">link</a></li>
             </ul>   
         </nav>
      </div>
 </div>

<div class="second">
  <div id="projects">
  <h1>Projects</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi nesciunt explicabo ipsam laudantium quaerat dolorem molestiae. Reprehenderit, perspiciatis, assumenda, repellat dolores dolore corporis doloribus voluptatem magni suscipit aperiam fugiat quia.
    </p>    
</div>

  

CSS

 html,body {
        height: 100%;
        padding: 0;
        margin: 0;
    }    
    .first {
        height: 100%;
        background-image: url(http://cs425729.vk.me/v425729136/4e67/6abwVXLTK9s.jpg);
        background-repeat: no-repeat;
        background-position: top center;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
    }
    .header {
        background: #333;
        height: 60px;
    }
    .logo, a {
        color: white;
    }
    .logo {
        float: left;
        padding: 20px;
    }
    nav {
        float: right;
        padding: 5px
    }
    nav li{
        display: inline-block;
        padding-right: 50px;
    }
    #projects {
        padding: 50px;
    }

我相信互联网浏览器会在背景上绊倒:封面。那里有工作。简单搜索。