Results 1 to 4 of 4
  1. #1
    baldidiot is offline Private Member
    Join Date
    January 2010
    Posts
    5,012
    Thanks
    428
    Thanked 2,289 Times in 1,524 Posts

    Default CSS vertical align issue

    I'm adding a small casino offer section to a sports site and about ready to chuck my laptop out of the window trying to vertically align the text. The annoying thing is I've done this before, just can't for the life of me remember how I did it (or figure out what I'm doing wrong).

    Basically I'm trying to make the bonus in the boxes on this page vertically align so it doesn't look weird when it's only on one line such as the virgin games one (most are two and I've fixed the height so the rest of the box is uniform): http://www.bettingoffers.org.uk/casino/

    I'm currently using:

    Code:
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    But it doesn't seem to be working the way I want it to.


    Any css gurus know what I'm doing wrong?
    onlinegamblingwebsites.com - Formally known as goodbonusguide.

    Gambling Domains: Small clear out of some of the domains we've been hoarding on Dan - see the list here. Prices negotiable, and willing to swap for decent links.

  2. #2
    banjo is offline Public Member
    Join Date
    April 2016
    Location
    UK
    Posts
    20
    Thanks
    5
    Thanked 3 Times in 3 Posts

    Default

    on the a tag

    vertical-align: middle;
    line-height: 56px;

    line height 2x what is set on the other boxes. so you'll need to assign this to these one-line boxes on their own, via inline css or a unique class/id


  3. #3
    baldidiot is offline Private Member
    Join Date
    January 2010
    Posts
    5,012
    Thanks
    428
    Thanked 2,289 Times in 1,524 Posts

    Default

    Ok cheers, different way to what I was thinking of but that works. Thanks!
    onlinegamblingwebsites.com - Formally known as goodbonusguide.

    Gambling Domains: Small clear out of some of the domains we've been hoarding on Dan - see the list here. Prices negotiable, and willing to swap for decent links.

  4. #4
    baldidiot is offline Private Member
    Join Date
    January 2010
    Posts
    5,012
    Thanks
    428
    Thanked 2,289 Times in 1,524 Posts

    Default

    Actually whilst going to try that I've spotted the error that was stopping my original way from doing it - I was defining the height of the bonus element, whereas I needed to add an additional element around the bonus and define the height of that instead.

    eg:

    Code:
    <div class="elementouter">
       <div class="elementinner">Bonus</div>
    </div>
    For anyone else in the same situation (or me for when I forget again) to get it to work use this:

    Code:
    .elementouter {height:50px}
    .elementinner {position: relative;top: 50%;transform: translateY(-50%);}
    Probably wouldn't have noticed if it weren't for the fact I went back to add additional classes, so cheers for that.
    onlinegamblingwebsites.com - Formally known as goodbonusguide.

    Gambling Domains: Small clear out of some of the domains we've been hoarding on Dan - see the list here. Prices negotiable, and willing to swap for decent links.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •