不能将1 div放在另一个下面

时间:2015-10-19 12:18:42

标签: html css twitter-bootstrap

我创建了一个名为“footer”的div,它在页面加载时始终显示在底部,在向下滚动时显示为up。现在我正在尝试使用col-6-lg(bootstrap)定位2x文本字段,它们应该在“页脚”下并且在滚动后可见。

body{
    background-image: url("../img/bg.png");
    background-size: cover;
    background-color: #01383b;
}

#footer {
    position: absolute;
    bottom: 0;
    width: 100%;
}

#content {
    background: #D0E5FF;
    padding: 20px;
    color: #00214B;
    font-family: sans-serif;
    font-weight: bold;
    font-size: 14px;
    line-height: 1.8;
}
#footer {
    opacity: 0.8;
    filter: alpha(opacity=40);
    background: rgb(14, 122, 128);
    line-height: 2;
    text-align: center;
    color: #042E64;
    font-size: 30px;
    font-family: sans-serif;
    font-weight: bold;
    text-shadow: 0 1px 0 #84BAFF;
    box-shadow: 0 0 15px #00214B
}

#button1{
    margin-top: 15px;
}

#button2{
    margin-top: 15px;
    margin-left: 95px;
}

.cd-container {
  width: 90%;
  max-width: 768px;
  margin: 2em auto;
}
.cd-container::after {
  /* clearfix */
  content: '';
  display: table;
  clear: both;
}

.cd-top {
  display: inline-block;
  height: 40px;
  width: 40px;
  position: fixed;
  bottom: 40px;
  right: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);

  overflow: hidden;
  text-indent: 100%;
  white-space: nowrap;
  background: #3cd8e1 url(../img/cd-top-arrow.svg) no-repeat center 50%;
  visibility: hidden;
  opacity: 0;
  -webkit-transition: opacity .3s 0s, visibility 0s .3s;
  -moz-transition: opacity .3s 0s, visibility 0s .3s;
  transition: opacity .3s 0s, visibility 0s .3s;
}
.cd-top.cd-is-visible, .cd-top.cd-fade-out, .no-touch .cd-top:hover {
  -webkit-transition: opacity .3s 0s, visibility 0s 0s;
  -moz-transition: opacity .3s 0s, visibility 0s 0s;
  transition: opacity .3s 0s, visibility 0s 0s;
}
.cd-top.cd-is-visible {
  visibility: visible;
  opacity: 1;
}
.cd-top.cd-fade-out {
  opacity: .5;
}
.no-touch .cd-top:hover {
  background-color: #3cd8e1;
  opacity: 1;
}
@media only screen and (min-width: 768px) {
  .cd-top {
    right: 20px;
    bottom: 20px;
  }
}
@media only screen and (min-width: 1024px) {
  .cd-top {
    height: 60px;
    width: 60px;
    right: 30px;
    bottom: 30px;
  }
}

.content{
    font-family: 'Open Sans';
    color: #fff;
}
<div id="footer">
   <div class="container">
      <div class="col-lg-8 col-lg-offset-2 text-center">
         <input type="image" src="img/true.png" alt="Submit" width="78" height="78" id="button1">
         <input type="image" src="img/false.png" alt="Submit" width="78" height="78" id="button2">
      </div>
      <div class="col-lg-4 pull-right">
         <a href="#0" class="cd-top cd-is-visible">Top</a>
      </div>
   </div>
</div>
<div class="container">
   <div class="col-lg-6 pull-left text-center">
      <h1>Да, това е!</h1>
   </div>
   <div class="col-lg-6 pull-left text-center">
      <h1>Не, това е Lorem Ipsum</h1>
   </div>
</div>

1 个答案:

答案 0 :(得分:1)

所以这是可能的解决方案。 你可以把两个盒子(页脚和底脚容器)都包起来,让我们把它称为:页脚包裹。 然后,设置.footer-wrap {position:absolute; bottom:0; width:100%;} 并从样式中删除#footer的定位类。

 /* #footer {
     position: absolute;
     bottom: 0;
     width: 100%;
   }*/

集:

 .footer-wrap {
    position: absolute;
    bottom: 0;
    width: 100%;
 }

以下是演示:https://jsfiddle.net/xvwqt9a0/

此处还有一个包含您的风格和html的演示:https://jsfiddle.net/xvwqt9a0/1/