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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:18:48+00:00 2026-06-03T07:18:48+00:00

I have a draggable div to which I want to set containment 80% of

  • 0

I have a draggable div to which I want to set containment 80% of parent. How can I achieve this ?

$( ".content-columns-sep" ).draggable({
            axis: "x",
            containment: "parent",
            cursor: "crosshair",
            grid: [10, 0],
            drag: function(event, ui) {
                ..
            }
        });
  • 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-03T07:18:49+00:00Added an answer on June 3, 2026 at 7:18 am

    As Neil suggested, you can use an internal div that is 80% of its parents size, and then constraint dragging to within that div. Here is a quick-and-dirty example on jsfiddle.

    For reference, the markup is:

    <div style="background-color: grey" class="draggable ui-widget-content">
        <div class="internal-area">
          <p style="background-color: red" id="draggable5" class="ui-widget-header">
            I'm contained within a percentage of my parent
          </p>
        </div>
    </div>
    

    The styles are:

    .draggable { width: 300px; height: 300px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
    .internal-area { width: 80%; height: 80%; background-color: white; margin-left: 30px; margin-top: 30px;}
    #draggable, #draggable2 { margin-bottom:20px; }
    #draggable { cursor: n-resize; }
    #draggable5 { cursor: e-resize; width: 70px;}
    #containment-wrapper { width: 90%; height:150px; border:2px solid #ccc; padding: 10px; }
    

    And the code is:

    $( "#draggable5" ).draggable({ containment: "parent" });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div, which has jQuery UI Draggable applied. What I want to
I have a draggable event set up like such: $(ids.label).draggable({ containment: ids.wrapper, revertDuration: 100,
I have a draggable table which all working fine, though I want to be
I have a draggable div of which when you drop it, it gives you
I have a DIV container which position is absolute and I'm having a draggable
I have a simple info div, which I want to make dragable across the
I have a div with overflow:hidden which contains image ( .draggable()) that is usually
I have a text box which is draggable anywhere in the div (see the
I have an image inside a div. I want that image to be draggable
I have a draggable image within a div. I can click on the image

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.