2012-07-23 90 views
-1

我有一個居中的DIV,並想知道我怎麼可以在其右側連接一個div, 有在頂部的標題DIV,然後將黃色居中DIV和這個社會共享DIV我我想附在右邊。CSS:將一個div爲中心的DIV

謝謝!!!

image of my divs

+0

你能表現出任何的代碼? – SpaceBeers 2012-07-23 21:20:51

+0

[DIV next to居中div]的可能重複(http://stackoverflow.com/questions/11433848/div-next-to-centered-div) – Purag 2012-07-23 21:25:58

回答

2

添加它的黃色DIV中,並將其定位爲:

#yellowdiv { position: relative; } 
#sidebar { position: absolute; left: 790px; top: 10px; } 
0

嘗試使黃色DIV的位置是:相對的,把側邊欄DIV中並使其位置:絕對值爲top:0和right:-XXX其中XXX是側邊欄的寬度加上您需要的邊距。

2

使用黃色div作爲棕色div的父元素是完全可行的;社交數據都是視頻的相關信息。在這種情況下,如果你願意,使用以下命令:

#video { 
position: relative; 
} 

#brown { 
position: absolute; top: 0; left: 100%; /* this guarantees that it'll line up at the very end of #video */ 
} 
1

演示

http://jsfiddle.net/KXvpV/1/

代碼

HTML

<div id="one"></div> 
<div id="two"> 
    <div id="social"></div> 
</div> 

CSS

#social { position: relative; top: 20px; right: -201px; }