Results 1 to 4 of 4
  1. #1
    manik's Avatar
    manik is online now Om Shanti!
    Join Date
    Apr 2008
    Location
    Boston, MA
    Posts
    13,233
    Thanks
    745
    Thanked 729 Times in 564 Posts
    Blog Entries
    4
    Feedback Score
    4 (100%)

    Default Vertical Center on Div

    There are lots of solutions online that claims to center elements (both text and image) vertically inside a div. I found too many ifs to get them working. Some requires known element height etc etc. This one solution from vdotmedia.com seem to really work. Works to center a div in the middle of the page as well as works to place elements (text, image etc) at vertical center of the div.

    So here is the modified version of the code:
    Code:
    <html>
    <head>
    <style type="text/css">
    /*change the height: 500px; below to height: 100%; to get the div centered vertically to the page; you would also need body html {height:100%;} to get that working.*/
    #container { width: 100%; height: 500px; display: table; }
    #position { display: table-cell; vertical-align: middle; width: 100%; text-align: center; }
    /*IE does not understand vertical-align:middle. to get it working on IE
    we have this conditional css*/
    <!--[if IE]>
    #container { position: relative; }
    #position { position: absolute; top: 50%; }
    #content { position: relative; top: -50%; }
    <![endif]-->
    </style>
    
    </head>
    <body>
    
    <div id="container">
        <div id="position">
            <div id="content">
                <img src="test.jpg" height="25" alt="" />
            </div>
        </div>
    </div>
    
    </body>
    </html>
    Free Classified Ads & BUSINESS/PROFESSIONAL SOCIAL NETWORK


  2. #2
    manik's Avatar
    manik is online now Om Shanti!
    Join Date
    Apr 2008
    Location
    Boston, MA
    Posts
    13,233
    Thanks
    745
    Thanked 729 Times in 564 Posts
    Blog Entries
    4
    Feedback Score
    4 (100%)

    Default

    ok I have to take part of the credit back. It does not seem to work with DOCTYPE XHTML there need some extra work to get it working.

    separate the main css and the conditional part on two files. then use a condition to load corresponding css.

    Or you can put the main css on a file and after the line that loads the file, put the conditional part; inside <head></head> tags.
    Free Classified Ads & BUSINESS/PROFESSIONAL SOCIAL NETWORK


  3. #3
    yawez.com is offline Master
    Join Date
    Dec 2008
    Posts
    1,099
    Thanks
    51
    Thanked 34 Times in 27 Posts
    Feedback Score
    0

    Default

    Ahh I see, thanks a lot Manik. You have excellent CSS knowledge
    This signiture is for sale - PM me if you want to place your link here.
    EARN MONEY NOW!

  4. #4
    krates98's Avatar
    krates98 is offline Master
    Join Date
    Nov 2008
    Posts
    2,904
    Thanks
    58
    Thanked 55 Times in 40 Posts
    Feedback Score
    0

    Default

    Hey site is good but i am kind of lost the site navigation is bad lol

Similar Threads

  1. Replies: 5
    Last Post: 04-27-2010, 10:35 PM
  2. Replies: 3
    Last Post: 05-21-2009, 05:08 AM
  3. Replies: 15
    Last Post: 12-24-2008, 04:11 PM
  4. Call Center Call
    By KahneFan in forum General Talk
    Replies: 4
    Last Post: 12-15-2008, 10:42 PM
  5. Partners wanted for Call Center business
    By enam in forum Joint Ventures
    Replies: 6
    Last Post: 06-24-2008, 05:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Partners: BOSTON WEB DEVELOPER, LLC   |   WEBCOSMO CLASSIFIEDS