如何在css中将div降低到顶部div的高度变化

时间:2018-03-13 21:35:37

标签: html css twitter-bootstrap twitter-bootstrap-3

我正在创建目标网页。当用户点击顶部栏上的按钮(在移动视图上)时,我会添加一个下拉列表。但我希望下拉列表在活动时切换为相对于其他div(切换为开启)。当用户点击按钮时,下拉列表应显示为div,底部的所有div应根据下拉高度向下移动。

以下是我正在处理的代码:



.top_menu {
  height: 70px;
  height: 70px;
  font-weight: 600;
  font-size: 20px;
  padding: 10px 0;
}

.top-nav-form {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: absolute;
  top: 0px;
  left: 0px;
  padding: 10px 0;
}

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

<div class="row top_menu">
  <div class="col-md-2 col-sm-2 top-menu-title">
    the page title

    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#top-form">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
  </div>

  <!-- this is the div of which i am talking about -->
  <div id="top-bar" class="col-md-10 col-sm-10">

    <div id="top-form" class="collapse navbar-collapse top-nav-form">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#top-form"><label class="toggle" for="nav-toggle"></label></button>

      <form class="page-form">
        <div class="row">
          <div class="col-md-1 col-sm-1">
            <label class="radio-inline"><input type="radio" name="optradio">Option 1</label>
          </div>
          <div class="col-md-1 col-sm-1">
            <label class="radio-inline"><input type="radio" name="optradio">Option 2</label>
          </div>

          <div class="col-md-4 col-sm-4">
            <input type="text" placeholder="Enter in a keyword or phrase">
          </div>

          <div class="col-md-2 col-sm-2">
            <div id="dropdown-outer-div" class="" data-toggle="collapse" data-target="#list-item">
              <span>Collapsible</span>

              <div id="list-item" class="collapse dropdown-list collapse">
                <ul>
                  <li>Web</li>
                  <li>Image</li>
                  <li>Shopping</li>
                  <li>Youtube</li>
                  <li>News</li>
                </ul>
              </div>
            </div>
          </div>

          <div class="col-md-2 col-sm-2">
            <div id="language-dropdown-outer-div" class="" data-toggle="collapse" data-target="#list-item-language">
              <span>Collapsible</span>

              <div id="list-item-language" class="collapse language-dropdown-list collapse">
                <ul>
                  <li>1</li>
                  <li>2</li>
                  <li>3</li>
                </ul>
              </div>
            </div>

          </div>
          <div class="col-md-2 col-sm-2">
            <input type="submit" value="Look up">
          </div>
        </div>
      </form>
    </div>
  </div>

</div>
&#13;
&#13;
&#13;

0 个答案:

没有答案