Vertical Align a <DIV>

Discussion in 'HTML and CSS' started by xarzu, Oct 19, 2011.

  1. xarzu

    xarzu

    Joined:
    Apr 3, 2007
    Messages:
    8
    Likes Received:
    0
    I have managed to horizontally align a Div object. Here is how I did it. I got the width and the height of the object I wanted to center (XAML CODE)

    HTML:
    <Grid  Background="White" Height="300" Width="738" VerticalAlignment="Center" HorizontalAlignment="Center">
    Then, in the html file that hosts the silverlight control I did this:

    HTML:
     <div id="silverlightControlHost" style="width:738px; height: 300px;  margin-top:auto; margin-bottom:auto;   margin-left: auto; text-align:center; margin-right: auto;">
    That puts the control centered horizontally at the top of the web page.

    Now, how do I center it vertically?
     
    xarzu, Oct 19, 2011
    #1
    1. Advertisements

  2. xarzu

    kgaurav

    Joined:
    Jan 16, 2015
    Messages:
    4
    Likes Received:
    0
    Location:
    India
    Give it line-height:300px, it will be center align vertically.
     
    kgaurav, Jan 16, 2015
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.