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 9196127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:46:59+00:00 2026-06-17T21:46:59+00:00

I have a fixed position element on a page. I want that element contained

  • 0

I have a fixed position element on a page. I want that element contained within a certain div tag of an ID or Class that I assign. Here is a fiddle with an example. In the example the floating bar should not go above or below the black box.

I do not mind using jQuery to change the functions, I am using v. 1.8.3.

Here as a site that shows an example of what I am after. Look on the left side.

Here is the code for the example:

HTML

<div class="wrapper">
<div class="top">
    <p>&nbsp;</p>
</div>
<div class="container">
<p>Floating Bar Should not go above this point.</p>

<p>&nbsp;</p>

</div>
<p>Floating Bar Should not go below this point.</p>
    <p>&nbsp;</p>

</div>

    <div class="add-this-container" >
    <!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_floating_style addthis_counter_style">
<a class="addthis_button_facebook_like" fb:like:layout="box_count"></a>
<a class="addthis_button_tweet" tw:count="vertical"></a>
<a class="addthis_button_google_plusone" g:plusone:size="tall"></a>
<a class="addthis_counter"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js">   </script>
<!-- AddThis Button END -->
</div>

CSS

.wrapper{
    height:1500px;
    background: #808080;
    width: 300px;
}
.container{
    background: #111;
    height: 600px;
}
.top{
    height: 400px;
    background: #7e0000;
}
.add-this-container{
position: absolute;
    left: 350px;
    top: 250px;
}
.addthis_floating_style{
    background: #ccc;
 }
p{
    color: white;
}
  • 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-06-17T21:47:00+00:00Added an answer on June 17, 2026 at 9:47 pm

    I added a few Id’s to your html to get their positions (header and footer)

    <div class="wrapper">
        <div class="top">
            <p>&nbsp;</p>
        </div>
        <div class="container">
        <p id="header">Floating Bar Should not go above this point.</p>
    
        <p>&nbsp;</p>
    
        </div>
        <p id="footer">Floating Bar Should not go below this point.</p>
            <p>&nbsp;</p>
    
    </div>
    
    <div class="add-this-container" >
            <!-- AddThis Button BEGIN -->
    <div class="addthis_toolbox addthis_floating_style addthis_counter_style">
    <a class="addthis_button_facebook_like" fb:like:layout="box_count"></a>
    <a class="addthis_button_tweet" tw:count="vertical"></a>
    <a class="addthis_button_google_plusone" g:plusone:size="tall"></a>
    <a class="addthis_counter"></a>
    </div>
    <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js"></script>
    <!-- AddThis Button END -->
    </div>
    

    This little script will stop the floating div once it reaches the header or footer breakoff points.
    I made the script to be bit ‘on the nose’ tho help you understnd what it does and when.
    It can be made a bit prettier, parhaps animate the position change.

    $(function(){
    
        //Scroll event, sets position on scroll
        $(document).scroll(function() { 
            position();        
        });
    
        // Set initial position on document ready
        position();
    });
    
    
    function position()
    {
                //Collect positions
            var floaterHeight = $('.addthis_floating_style').height();
            var headerBreakoff = $('#header').offset().top + $('#header').height();
            var footerBreakoff = $('#footer').offset().top;
    
            var newTop = $(document).scrollTop() + 20; // this will be position when between header and footer        
    
            if(newTop <= headerBreakoff) // Above header
            {        
                newTop = headerBreakoff;
            }
            else if(newTop + floaterHeight >= footerBreakoff) // Below footer
            {
                newTop =  footerBreakoff - floaterHeight;
            }
    
            //Set position
            $(".addthis_floating_style").offset({ top: newTop});
    }
    

    Here is the fiddle

    http://jsfiddle.net/urbanbjorkman/BJ6EP/

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

Sidebar

Related Questions

I have a div element that I want to move with the page for
I have a object with position:fixed that I'm moving around a page in response
I have the following element in my page: <div id=banner class=disappear>Hello</div> The CSS for
I have div as watermark on page. div {position: fixed;} But in the area
I have a div whose position has been fixed. Everything is fine till the
I have this situation where i want to call a certain element depended on
Here I have a div in a right sidebar that supposed to act in
Here I have a div on the bottom of right sidebar that supposed to
I have a mobile web app that displays a dialog box within a position:
Here is jsFiddle for better understanding: http://jsfiddle.net/BzYcZ/ I have some div that have scrollbars.

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.