Aspect Ratio Lock for Banner Images

CraigCoxson
CraigCoxson
edited November 2013 in Campaign Portal Building
.campaign-public-layout #banner-container .campaign-banner-image {
display: block;
height: 0;
padding-bottom: 42.86%;
overflow: hidden;
}

This sets the Banner to a specific aspect ratio. In my case it is 7:3. The % (which controls the height of the box) is figured as: (W / H) * 100

Comments

  • CraigCoxson
    CraigCoxson
    Posts: 20
    Oops. Math problem. The formula is (H / W) * 100. Sorry, this should work a little better.
  • GamingMegaverse
    GamingMegaverse
    Posts: 3,001
    Used it- works great! Thanks Craig!

    Just trying to help out.

  • ChainsawXIV
    ChainsawXIV
    Posts: 530
    Alternatively, the following should do all the math for you, scaling the banner so it fits in the standard space they've allotted (and fixes the small banners on private pages gracefully too):

    .campaign-banner-image{ background-size: 100%; background-repeat: no-repeat; }
Sign In or Register to comment.

April 2024
Season of Strife

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions