html - bootstrap 崩溃以显示它工作的 div 但如何使其不影响副元素?

标签 html css twitter-bootstrap

我正在使用 bootstrap collapse 来显示一个 div,但是当我使用它时,当一个 div 通过折叠打开时,副元素会受到影响,就像下降一样。我如何使副产品不会掉落并留在原位

这里我制作了一个Jsfiddle example

这是我的html代码

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<div class="right-lower-container">
  <div class="testing-notification">
    <span class="glyphicon glyphicon-comment notification-bar" data-toggle="collapse" data-target="#testing1"></span>
    <div id="testing1" class="collapse notification-block">
      testing 1
    </div>
  </div>
  <span class="btn glyphicon glyphicon-bell notification-bar" data-toggle="collapse" data-target="#testing2"></span>
  <div id="testing2" class="collapse notification-block">
    testing2
  </div>
  <a class="option-font" href="#">
    <span>
                                new items
                            </span>
  </a>
  <a class="option-font" href="#">
    <span class="glyphicon glyphicon-search">
                                search
                            </span>
  </a>
</div>

这是我的CSS代码

.right-lower-container {
  height: 40%;
  width: 100%;
  display: block;
  vertical-align: top;
  text-align: right;
}

.notification-bar {
  color: black;
  margin-right: 2.5%;
}

.notification-bar:hover {
  color: gray;
}

.notification-block {
  width: 100px;
  height: 100px;
}

.testing-notification {
  display: inline-block;
  width: 20%;
}

#testing1,#testing2{
  background-color:red;
  width:100px;
  height:200px;
}

最佳答案

添加以下CSS:

.option-font,
.notification-bar,
.testing-notification {
    display: inline-block;
    vertical-align: top;
}

关于html - bootstrap 崩溃以显示它工作的 div 但如何使其不影响副元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37538711/

相关文章:

javascript - HTML页面添加JS,浏览器差异

css - 动态 Div 在鼠标悬停时更改宽度

javascript - 带图像的 HTML/CSS 模态对话框(Sweetalert 或其他)

twitter-bootstrap - 如何使用Bootstrap在手机上显示表格?

html - 如何在 Bootstrap 中以自定义宽度在页面上的 1 行中显示 5 个输入

javascript - 检查文本框中是否按下引号

html - 如何在相对位置或任何地方在左上/下左或右上/右下实现内联 block ?

html - VBA 在票务中抓取数据

javascript - 仅在页面刷新后加载 Jquery 脚本

javascript - Slick Carousel - 设置第一张幻灯片