2015-11-04 89 views
-1

我有一個包裝一切的頁面包裝div。此頁面div不是整頁,而是95%的寬度和高度以及邊框。如何在包裝div中顯示彼此相鄰的div?

在這個我想有三個彼此相鄰,如三個傀儡,然後一個在他們之下。

我該如何做到這一點與CSS?

+0

你能分享你的代碼來幫助人們回答嗎? – 2015-11-04 23:44:05

+0

代碼可以幫助我們Stooges :) –

+0

取決於您想給這些列的屬性。請更多代碼。 – Daniel

回答

0

這方面,我一直使用的網站佈局,包括響應式佈局。

CSS:

.wraper{ 
    width: 95%; 
    border: 1px solid red; 
} 
.one, .two, .three{ 
    display:block; 
    width:33%; 
    border: 1px solid green; 
    box-sizing: border-box; 
} 
.one{ 
    float:left; 
} 
.two{ 
    margin:0 auto; 
} 
.three{ 
    float:right; 
} 
.four{ 
    clear:both; 
    display:block; 
    width:100%; 
    border:1px solid red; 
    box-sizing: border-box; 
} 

HTML:

<div class="wraper"> 
    <div class="one">1</div> 
    <div class="three">3</div> 
    <div class="two">2</div> 
    <div class="four">4</div> 
</div> 

DEMO

+0

謝謝,這爲我做了詭計。我不知道有關這兩個選項的清楚:這個選項也幫助了其他一些項目! – tadamhicks

+0

如果有幫助,請檢查正確答案並投票。 :) –

0

本質上要顯示你在一排在你的CSS display: inline希望div的,所以這是DIV 1,2和3

HTML:

<div class="wrap"> 
    <div class="one">1</div> 
    <div class="two">2</div> 
    <div class="three">3</div> 
    <div class="four">4</div> 
</div> 

CSS:

.wrap{ 
    height: 95%; 
    width: 95%; 
    border: 1px solid red; 
} 

.one, .two, .three{ 
    display: inline; 
    border: 1px solid green; 
} 

CODEPEN DEMO

0

你也可以使用float有彼此相鄰的div。

HTML:

<div class="wrapper"> 
     <div class="stack">Stack</div> 
     <div class="stack">Stack</div> 
     <div class="stack">Stack</div> 
     <div class="full">Full</div> 
</div> 

CSS:

.wrapper { 
    height: 95%; 
    width: 95%; 
} 

.stack { 
    display: block; 
    width: 33%; 
    height: 100px; 
    float: left; 
    border: 1px solid red; 
} 

.full { 
    clear: both; 
    width: 100%; 
    height: 100px; 
    border: 1px solid red; 
} 

您將需要清楚地顯示全尺寸之一。