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

  • SEARCH
  • Home
  • 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 398045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:42:34+00:00 2026-05-12T16:42:34+00:00

I have two elements: 1. A parent of fixed height, overflow:hidden 2. Its child,

  • 0

I have two elements:

1. A parent of fixed height, overflow:hidden

2. Its child, of larger fixed height.

<style type="text/css">
    .myList {list-style:none; margin:0px; padding:1px;}
    .myList li{ height:50px;  margin:4px; padding:2px;}
    .dragPanel {height:230px; border:solid; overflow:hidden;}
</style>

<div class="dragPanel">
    <ul class="myList">
        <li>1</li>
        <li>2</li>
        ...   ....
        <li>8</li>
        <li>9</li>
    </ul>
</div>

I want to be able to drag the list up and down within the parent div. I am using the jquery ui draggable plugin to achieve verticle dragging, but I am unsure how to constrain the list within the parent div.

<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.draggable.js"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $('.dragPanel').addClass("hover");
        $('.myList').draggable({ axis: 'y' });
    });
</script>

How would I go about setting verticle upper and lower limits for the posistion of the list?

  • 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-12T16:42:35+00:00Added an answer on May 12, 2026 at 4:42 pm

    Ok,

    Here is the route I have gone down…

    When the page is loaded, I add a container div around the draggable list. I set it’s height to twice that of the list, then position it up the page a little:

    <script type="text/javascript">
      $(document).ready(function() {
          CreateContainerDiv();
          $('.dragPanel').addClass("hover");
          $('.myList').draggable({ axis: 'y', containment: 'parent' });
      });
    
        function CreateContainerDiv() {
            var dragPanel = $('.dragPanel');
            var dragTarget = $('.myList');
    
            // add the container panel
            var newPanelHeight = dragTarget.outerHeight() * 2 - dragPanel.outerHeight();
            dragTarget.wrap(document.createElement("div"));
    
            // set its height and put it in the right place
            dragTarget.parent().css("height", newPanelHeight);
            dragTarget.parent().css("position", "relative");
            var newPanelPosition = ((dragTarget.outerHeight() * -1) / 2);
            dragTarget.parent().css("top", newPanelPosition);         
        }
    </script>
    

    The list is then contained to this new element.

    This appears to do the job, but the positioning is all a little shakey if the list has any padding / margin applied. Any thoughts on that would be appreicated!

    ——Edit ———

    Ok, I think I have solved the placement issue. I have turned this into a plugin so other people don’t have to spend time creating this functionality.

    jQuery Drag-gable List at Github

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

Sidebar

Related Questions

I have two divs like so <div id=parent style=width:100px:overflow:hidden;> <div id=child> tooooooooooooooooooooo much content
I have two div -elements, the top one has the height of 40% and
I have a gridview in which there are two elements in each of its
let's suppose to have following code: <body style=overflow: hidden> <div class=wall> <button>New</button> <div class=prova>
I have two float elements, right and left. The parent element for all of
In CSS the overflow:hidden is set on parent containers in order to allow it
I'm trying to move child div elements between two different parent divs using jQuery
For example, I have two elements in an enum. I would like the first
I have two span elements that I would like to stay on the same
I have two div elements that are twins (i.e. their dimensions and contents are

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.