ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Vertical CSS Alignment Help!

November 21, 2012 9:42am

Subscribe [2]
  • #1 / Nov 21, 2012 9:42am

    maury.mccown

    87 posts

    Hey all

    REALLY showing my coding age with this one! I’m working on a new site, and I want to get a navigation bar vertically aligned to center with a title image. I’ve attached a Photoshop image, tlpcss01.jpg, showing how I want it to look.

    The relevant CSS (ignore the poor naming schemes…I’ve just been copy/pasting my other CSS and adding a character):

    #titlewrapper {
     margin: auto;
     text-align: center;
     height:189px;
    }
    .float_left {
     float: left;
     padding-right: 20px;
    }
    .float_left2 {
     height:189px;
     float: right;
     position:relative;
     top:50%;
     vertical-align:middle;
     display:inline-block;
    }

    Here’s the page code in EE:

    <div class="title wrapper">
    
    <div class="float_left">
    <a href="http://www.threadedleafproject.org/graphics/TLPlogo01.png">http://www.threadedleafproject.org/graphics/TLPlogo01.png</a>
    </div>
    
    
    <div class="float_left2">
    <a href="http://{homepage}/index.php" class="newsbutton"></a><a href="http://{homepage}/index.php/pages/donate" class="donatebutton"></a>
    </div>
    
    </div>

    If you look at tlpcss02.jpg, you see my problem: no matter what I’ve tried, I cannot get the navigation images to vertically align with the main graphic on the left. I thought that by placing everything inside my titlewrapper, the float_left2 would inherit the height of that parent, so then I could set the top to 50%. Ugh.

    Anyway, I’m pulling my hair out trying to get this to work.

    Any help would be MUCH appreciated!

  • #2 / Nov 21, 2012 10:39am

    Rob Allen

    3114 posts

    Try using line-height ...eg

    .float_left2 {
     height:189px;
     line-height: 189px;
     float: right;
     position:relative;
     display:inline-block;
     
    }
  • #3 / Nov 21, 2012 1:23pm

    maury.mccown

    87 posts

    That did it! THANKS!!!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases