Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 535893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:45:53+00:00 2026-05-13T09:45:53+00:00

I created a plugin to bottom-align a element. In it’s simplest form I did

  • 0

I created a plugin to bottom-align a element. In it’s simplest form I did this:

  1. Get height of outerElement (DIV)
  2. Get height of current element
  3. result = outerHeight – height of current element
  4. sett CSS attribute ‘top’ = result.

And it works… in Firefox and IE8, but not in Opera or Google Chrome.

I’m guessing it has to do with borders, padding and margin. So what do I have to do in order to make it work cross-browser?

UPDATE
Code has been revised and is working now.

(function($){
    $.fn.alignBottom = function() 
    {

        var defaults = {
            outerHight: 0,
            elementHeight: 0
        };

        var options = $.extend(defaults, options);
        var bpHeight = 0; // Border + padding

        return this.each(function() 
        {
            options.outerHight = $(this).parent().outerHeight();
            bpHeight = options.outerHight - $(this).parent().height();
            options.elementHeight = $(this).outerHeight(true) + bpHeight;


            $(this).css({'position':'relative','top':options.outerHight-(options.elementHeight)+'px'});
        });
    };
})(jQuery);

The HTML could look something like this:

div class="myOuterDiv">
    <div class="floatLeft"> Variable content here </div>
    <img class="bottomAlign floatRight" src="" /> </div>
</div>

and applying my jQuery plugin:

jQuery(".bottomAlign").alignBottom();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:45:53+00:00Added an answer on May 13, 2026 at 9:45 am

    You probably need to look into the outerHeight() jQuery method:

    options.outerHight = $(this).parent().outerHeight();
    options.elementHeight = $(this).outerHeight( true ); // Include margins
    

    You also probably need to play with .position().top which is the distance the element already is moved away from the top of the containing element:

    var new_top = $(this).parent().outerHeight() - $(this).outerHeight() - $(this).position().top;
    

    Another approach

    A couple things about position:relative. Elements positioned like this will take up space, but can be shifted in any direction. Note that shifting them does not change where they took up space, only where the element displays.

    About position:absolute. An absolutely positioned element does not take up space, but needs to be inside an element that has position (i.e. position:relative)

    So, in straight CSS:

    .myOuterDiv { position: relative }
    .bottomAlign { position: absolute; bottom: 0 }
    

    But note that any position it used to take up (i.e. because of the float right) it will no longer take up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 279k
  • Answers 279k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This KB article explain it May 13, 2026 at 3:30 pm
  • Editorial Team
    Editorial Team added an answer You mention BAT files so perhaps what you want is… May 13, 2026 at 3:30 pm
  • Editorial Team
    Editorial Team added an answer a += x * sgn(b-a) Where sgn is the sign… May 13, 2026 at 3:30 pm

Related Questions

I've created a custom jQuery horizontal menu with drop downs. Initially it just faded
I am trying to find a plugin or a solid way to narrow a
In our application we're using jdMenu plugin to create a hierarchical menu from nested
I'm trying to create a jQuery plugin, inside I need to do an AJAX
Hi this is pretty basic jQuery stuff but i am a little lost. So

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.