css - Add div next to other centered div -


i want add div right of other div positioned in center. shown in image:

enter image description here

i have html far:

<div id= "top-menu-wrapper">   <div id="top-menu">          </div>   <div id="social">   </div> </div> 

the css:

#header #top-menu {     display           : inline-block;     width             : 764px;     height            : 55px;     margin            : auto;    }  #header #social {     display           : inline-block;     width             : 100px;     height            : 55px;        margin-left       : 25px;  }  #header #top-menu-wrapper {     display           : block;     text-align        : center;     margin-bottom     : 25px; } 

since widths fixed, calculate left offset of each div, , put left margin without using central alignment.

or, if container fluid, center problematic div inside right-floated subcontainer width of

(top container width - central div width) / 2) (that represents remaining space @ right)

you'll make best if use javascript window resize listener recalculate position on every resize event. (although you'd prefer use css only, i'd suggest js best results)


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -