Search code examples
csspositioningcss-float

Centering images horizontally and vertically within a div of vary width and heighth


I need to center a forward and back arrow on either side of an image within a larger div. The div's width and height vary according to the size of the image.

I have a live version of my work so far here: http://danapaigetrentlage.com/cfsa-comps/lff-aboutgoods.html

And here's a jsfiddle to play with: http://jsfiddle.net/thwackukulele/4zHyd/ Though I don't know how much use that will be without the images linked in.

You'll see the forward and backward arrows are at the top of the blue area to either side of the image. I want them to be centered horizontally and vertically within this blue area.

I know that I am using a lot of positioning, and if there's an all around better way to attack this layout, please let me know. This is the best I could come up with. I am eventually handing these layouts off to a developer who is adding database CMS functionality. So my code doesn't need to be perfect, it just has to illustrate my intentions so that he can understand.

Thanks for any help in advance!!


Solution

  • .framewrap-fb{ position:relative; }
    .rightarrow, .leftarrow{ position:absolute; top:50%; margin-top:-32px; width:64px; height:64px}
    .leftarrow{left:0}
    .rightarrow{right:0}