css: Attach a div to a Centered div


I have a centered div and was wondering how can i attach a div on its right, there is a title DIV on top, then the yellow centered DIV and this SOCIAL SHARING DIV I'd like to attach on the right.

Thank you!!!

image of my divs

Problem courtesy of: themike


Add it inside the yellow div, and position it as follows:

#yellowdiv { position: relative; }
#sidebar { position: absolute; left: 790px; top: 10px; }
Solution courtesy of: bfavaretto


Try making the yellow div position:relative, put the sidebar div inside it and make it position:absolute with values of top:0 and right:-XXX where XXX is the width of the sidebar plus the margin you require.

Discussion courtesy of: Billy Moat

It would be perfectly feasible to use the yellow div as the parent element for the brown div; the social data is all relevant info to the video. In that case, if you want, use the following:

#video {
 position: relative;

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





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


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


Discussion courtesy of: GG.

This recipe can be found in it's original form on Stack Over Flow.