在html的同一行划分

时间:2016-11-08 07:53:46

标签: html css twitter-bootstrap

不使用HTML表是否有任何解决方案将2个div放在一行中的不同列和同一行上,同一列上的2个div一个在另一个上面?

这是一张更好地解释的图片:

enter image description here

我正在使用bootstrap,我正试图达到这个目的: enter image description here

这就是我现在得到的: enter image description here

如果有不同的行,我如何将底部DIV 1和DIV 2对齐?

此时我的html网格如下: enter image description here

.label {
  font-size: 15px;
}
` #liveChat {
  background-color: #1C3A69;
}
`
<div class="container">
  <div class="col-lg-8 col-lg-offset-2 col-md-8 col-md-offset-2 col-sm-12 col-xs-12 panel" id="mainDiv">
    <header class="row panel-heading"> <span>Tax</span>Extension.com</header>

    <div id="liveChat" class="row ">

      <div class="container">
        <div class="row">
          <div id="taxExtensions" class="label col-md-2 leftItems">
            My Tax Extensions
          </div>
          <div id="UpdateAccount" class="label  col-md-1 leftItems ">
            Update Account Info
          </div>
          <div class="label col-md-2 col-md-offset-7 ">
            <div>
              LIVE CHAT
            </div>
            <div>
              Support is Online
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="panel-body row" id="mainContent" style="min-height:200px; background-color:aquamarine;">

    </div>

    <footer class="panel-footer row">Footer</footer>
  </div>
</div>

2 个答案:

答案 0 :(得分:3)

如果导航栏具有预定义的高度

,则可以像这样制作一个简单的

基本上它只是一堆div

&#13;
&#13;
List<int> myList = result.ToList();
&#13;
#div-l{
background-color:red;
}
#div-m{
background-color:blue;
}
#div-r1{
background-color:green;
}
#div-r2{
background-color:grey;
}
.single-stack{
height:50px;
float:left;
width:33%
}
.double-stack{
height:25px;
float:left;
width:33%
}
&#13;
&#13;
&#13;

答案 1 :(得分:2)

如果您正在使用导航栏。那为什么不使用bootstrap navbar组件? 看一下这个。您还可以看到它here

HTML

<nav class="navbar navbar-default sample">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <!-- <a class="navbar-brand" href="#">Brand</a> -->
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
                <div class="row right-items text-center">
                    <div class="col-xs-12">LIVE CHAT</div>
                    <div class="col-xs-12">Support is Online</div>
                </div>
            </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

CSS:

.sample{
    background: #1c3a69;
}

nav{
    color: #fff;
}

.right-items {
     margin-top: 5px;
}