2016-11-08 49 views
2

沒有使用HTML表是否有任何解決方案將2個div放在同一行中的不同列上,在同一列上放置兩個div在另一個上面?在HTML中同一行的div

這是解釋更好的圖像:

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

你可以提供一個工作樣本/小提琴? – GvM

+0

你在製作導航欄嗎? – claudios

+0

是啊,有點:) – TrulyXax

回答

2

如果你工作了導航欄。那爲什麼不使用bootstrap導航欄組件? 看看這個。您還可以看到它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; 
} 
3

一個簡單的人可以做出這樣的,如果導航欄已預定高度

基本上它只是一堆divs

#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% 
 
}
<div id="div-l" class="single-stack">&nbsp;</div> 
 
<div id="div-m" class="single-stack">&nbsp;</div> 
 
<div id="div-r1" class="double-stack">&nbsp;</div> 
 
<div id="div-r2" class="double-stack">&nbsp;</div>