2014-09-03 79 views
0

我想定位一些5个div。定位浮动div

2周的div浮动到左侧,堆放 1个中的div 2的div浮动到右侧

的问题是,2右格是停留在中间的div底下,甚至当我尝试做中间股票变小。

我该如何把正确的浮动div放在右边,而不是在我的中心div下?

+0

你能提供一个草图或图片吗? – 2014-09-03 09:02:44

+0

可以请你在jsfiddle中提供一些代码吗? – Pbk1303 2014-09-03 09:03:34

回答

0
<div class="wrap"> 
    <div class="col-l"> 
    <div>your 1st div</div> 
    <div>your 2nd div</div> 
    </div> 
    <div class="col-m">your 3rd div</div> 
    <div class="col-r"> 
    <div>your 4th left div</div> 
    <div>your 5th left div</div> 
    </div> 
</div> 
<style> 
.wrap { width: 900px; clear: both; overflow: hidden; } 
.col-l { width: 300px; float: left; } 
.col-m { width: 200px; float: left; } 
.col-r { width: 400px; float: right; } 
</style> 
1

这是你想要的吗?

HTML:

<div class="container"> 
    <div class="box left"></div> 
    <div class="box left"></div> 

    <div class="box middle"></div> 

    <div class="box right"></div> 
    <div class="box right"></div> 
</div> 

CSS:

.container { 
    text-align: center; 
} 

.box { 
    border: 1px solid black; 
    height: 100px; 
    width: 100px; 
} 

.left { 
    float:left; 
} 

.middle { 
    display: inline-block; 
} 

.right { 
    float: right; 
} 

Here's a fiddle.

0

.topLeft { height:310px;

     width: 200px; 

        float: left; 

     margin-bottom:50px; 

      } 
    .nextLeft { 
        height: 700px; 

        width: 200px; 

     clear: both; 

        float: left; 
      } 



    .middle{ 

    margin:0 230px; 

    width:700px; 





    } 
      .topRight { 

        height: 200px; 

        width: 200px; 

        float: right; 


        } 
      .nextRight { 
        height:200px; 

        width: 200px; 

     border-radius: 1em 2em;       
        float: right; 

     clear: both; 


      } 
+0

这是我做的代码。我希望正确的浮动元素从中间div下移动。 – Kgomotso 2014-09-11 09:47:56