Grow your CSS skills. Land your dream job.

Center div within dynamic height and width?

  • # October 26, 2011 at 6:55 am

    Hello!

    I’m trying to center a div that holds the title of my post in my wordpress theme – the images will all be different sizes. Currently I’m using relative/absolute positing with percentages on the top and left values. This is not working perfectly.

    Does anyone have any ideas on how to achieve this?

    Link:
    http://juniorvicepresidents.com/

    Cheers!

    # October 26, 2011 at 11:24 am

    This as always been a pain, but it can be done. The easiest way is (I’m gonna get yelled at here) to use a table. But there are other solutions out there.
    Cliff

    # October 26, 2011 at 11:53 am

    Hey Niplo, I actually wrote an article about a way to do this with jQuery on my blog a little while ago: http://johndoesdesign.com/blog/2011/jquery/centering-an-element-using-jquery/ Let me know if it’s helps. Scroll down to the bottom for the final code.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".