jquery ui resiable- How to force to resize within the parent?










0















There are three columns in a web page that are resizable. I need to



  1. Force the columns width not to be more than the width of the parent

  2. They all together must fill the width of the parent

  3. Only the internal borders must be movable.

So if one column width is getting bigger, the other one must get smaller and vice versa.



To do so I need to I tried the jquery ui resiable and set the containment: "parent" but none of the 3 items are done. This is the code



 <style>
.resizable
height: 300px;
border: 1px solid red;
float: left;
min-width: 20%;

</style>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<div class="card-header text-right"> __('Messages') </div>
<div class="card-body ">
<div id="usersColumn" class="resizable">
</div>
<div id="messagesColumn" class="resizable"></div>
<div id="messageColumn" class="resizable"></div>
</div>
</div>
</div>
</div>
</div>
<script>
$(function ()
$(".resizable").resizable(
containment: "parent",
);
);
</script>


What shall I do?
Thanks










share|improve this question


























    0















    There are three columns in a web page that are resizable. I need to



    1. Force the columns width not to be more than the width of the parent

    2. They all together must fill the width of the parent

    3. Only the internal borders must be movable.

    So if one column width is getting bigger, the other one must get smaller and vice versa.



    To do so I need to I tried the jquery ui resiable and set the containment: "parent" but none of the 3 items are done. This is the code



     <style>
    .resizable
    height: 300px;
    border: 1px solid red;
    float: left;
    min-width: 20%;

    </style>
    <div class="container">
    <div class="row justify-content-center">
    <div class="col-md-12">
    <div class="card">
    <div class="card-header text-right"> __('Messages') </div>
    <div class="card-body ">
    <div id="usersColumn" class="resizable">
    </div>
    <div id="messagesColumn" class="resizable"></div>
    <div id="messageColumn" class="resizable"></div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <script>
    $(function ()
    $(".resizable").resizable(
    containment: "parent",
    );
    );
    </script>


    What shall I do?
    Thanks










    share|improve this question
























      0












      0








      0








      There are three columns in a web page that are resizable. I need to



      1. Force the columns width not to be more than the width of the parent

      2. They all together must fill the width of the parent

      3. Only the internal borders must be movable.

      So if one column width is getting bigger, the other one must get smaller and vice versa.



      To do so I need to I tried the jquery ui resiable and set the containment: "parent" but none of the 3 items are done. This is the code



       <style>
      .resizable
      height: 300px;
      border: 1px solid red;
      float: left;
      min-width: 20%;

      </style>
      <div class="container">
      <div class="row justify-content-center">
      <div class="col-md-12">
      <div class="card">
      <div class="card-header text-right"> __('Messages') </div>
      <div class="card-body ">
      <div id="usersColumn" class="resizable">
      </div>
      <div id="messagesColumn" class="resizable"></div>
      <div id="messageColumn" class="resizable"></div>
      </div>
      </div>
      </div>
      </div>
      </div>
      <script>
      $(function ()
      $(".resizable").resizable(
      containment: "parent",
      );
      );
      </script>


      What shall I do?
      Thanks










      share|improve this question














      There are three columns in a web page that are resizable. I need to



      1. Force the columns width not to be more than the width of the parent

      2. They all together must fill the width of the parent

      3. Only the internal borders must be movable.

      So if one column width is getting bigger, the other one must get smaller and vice versa.



      To do so I need to I tried the jquery ui resiable and set the containment: "parent" but none of the 3 items are done. This is the code



       <style>
      .resizable
      height: 300px;
      border: 1px solid red;
      float: left;
      min-width: 20%;

      </style>
      <div class="container">
      <div class="row justify-content-center">
      <div class="col-md-12">
      <div class="card">
      <div class="card-header text-right"> __('Messages') </div>
      <div class="card-body ">
      <div id="usersColumn" class="resizable">
      </div>
      <div id="messagesColumn" class="resizable"></div>
      <div id="messageColumn" class="resizable"></div>
      </div>
      </div>
      </div>
      </div>
      </div>
      <script>
      $(function ()
      $(".resizable").resizable(
      containment: "parent",
      );
      );
      </script>


      What shall I do?
      Thanks







      jquery css jquery-ui






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 11:09









      No oneNo one

      6721031




      6721031






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You need to:




          Use the containment option to specify a parent DOM element or a jQuery selector




          jquery UI - resizable






          $(function() 
          $(".resizable").resizable(
          containment: ".card-body"
          );
          );

          .card-body 
          display: flex;


          .resizable
          height: 300px;
          border: 1px solid red;
          flex: 1 1 auto;

          <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
          <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

          <div class="container">
          <div class="row justify-content-center">
          <div class="col-md-12">
          <div class="card">
          <div class="card-header text-right"> __('Messages') </div>
          <div class="card-body ">
          <div id="usersColumn" class="resizable">
          </div>
          <div id="messagesColumn" class="resizable"></div>
          <div id="messageColumn" class="resizable"></div>
          </div>
          </div>
          </div>
          </div>
          </div>








          share|improve this answer























          • It is good, but here is problem, moving the right middle border causes movement of middle left border. It is not good at all. If I name the columns as (1,2,3), moving 2 border to right must causes reducing 3 width and increasing 2 with. But it reduces 1 width as well.

            – No one
            Nov 13 '18 at 11:45










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279702%2fjquery-ui-resiable-how-to-force-to-resize-within-the-parent%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You need to:




          Use the containment option to specify a parent DOM element or a jQuery selector




          jquery UI - resizable






          $(function() 
          $(".resizable").resizable(
          containment: ".card-body"
          );
          );

          .card-body 
          display: flex;


          .resizable
          height: 300px;
          border: 1px solid red;
          flex: 1 1 auto;

          <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
          <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

          <div class="container">
          <div class="row justify-content-center">
          <div class="col-md-12">
          <div class="card">
          <div class="card-header text-right"> __('Messages') </div>
          <div class="card-body ">
          <div id="usersColumn" class="resizable">
          </div>
          <div id="messagesColumn" class="resizable"></div>
          <div id="messageColumn" class="resizable"></div>
          </div>
          </div>
          </div>
          </div>
          </div>








          share|improve this answer























          • It is good, but here is problem, moving the right middle border causes movement of middle left border. It is not good at all. If I name the columns as (1,2,3), moving 2 border to right must causes reducing 3 width and increasing 2 with. But it reduces 1 width as well.

            – No one
            Nov 13 '18 at 11:45















          1














          You need to:




          Use the containment option to specify a parent DOM element or a jQuery selector




          jquery UI - resizable






          $(function() 
          $(".resizable").resizable(
          containment: ".card-body"
          );
          );

          .card-body 
          display: flex;


          .resizable
          height: 300px;
          border: 1px solid red;
          flex: 1 1 auto;

          <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
          <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

          <div class="container">
          <div class="row justify-content-center">
          <div class="col-md-12">
          <div class="card">
          <div class="card-header text-right"> __('Messages') </div>
          <div class="card-body ">
          <div id="usersColumn" class="resizable">
          </div>
          <div id="messagesColumn" class="resizable"></div>
          <div id="messageColumn" class="resizable"></div>
          </div>
          </div>
          </div>
          </div>
          </div>








          share|improve this answer























          • It is good, but here is problem, moving the right middle border causes movement of middle left border. It is not good at all. If I name the columns as (1,2,3), moving 2 border to right must causes reducing 3 width and increasing 2 with. But it reduces 1 width as well.

            – No one
            Nov 13 '18 at 11:45













          1












          1








          1







          You need to:




          Use the containment option to specify a parent DOM element or a jQuery selector




          jquery UI - resizable






          $(function() 
          $(".resizable").resizable(
          containment: ".card-body"
          );
          );

          .card-body 
          display: flex;


          .resizable
          height: 300px;
          border: 1px solid red;
          flex: 1 1 auto;

          <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
          <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

          <div class="container">
          <div class="row justify-content-center">
          <div class="col-md-12">
          <div class="card">
          <div class="card-header text-right"> __('Messages') </div>
          <div class="card-body ">
          <div id="usersColumn" class="resizable">
          </div>
          <div id="messagesColumn" class="resizable"></div>
          <div id="messageColumn" class="resizable"></div>
          </div>
          </div>
          </div>
          </div>
          </div>








          share|improve this answer













          You need to:




          Use the containment option to specify a parent DOM element or a jQuery selector




          jquery UI - resizable






          $(function() 
          $(".resizable").resizable(
          containment: ".card-body"
          );
          );

          .card-body 
          display: flex;


          .resizable
          height: 300px;
          border: 1px solid red;
          flex: 1 1 auto;

          <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
          <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

          <div class="container">
          <div class="row justify-content-center">
          <div class="col-md-12">
          <div class="card">
          <div class="card-header text-right"> __('Messages') </div>
          <div class="card-body ">
          <div id="usersColumn" class="resizable">
          </div>
          <div id="messagesColumn" class="resizable"></div>
          <div id="messageColumn" class="resizable"></div>
          </div>
          </div>
          </div>
          </div>
          </div>








          $(function() 
          $(".resizable").resizable(
          containment: ".card-body"
          );
          );

          .card-body 
          display: flex;


          .resizable
          height: 300px;
          border: 1px solid red;
          flex: 1 1 auto;

          <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
          <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

          <div class="container">
          <div class="row justify-content-center">
          <div class="col-md-12">
          <div class="card">
          <div class="card-header text-right"> __('Messages') </div>
          <div class="card-body ">
          <div id="usersColumn" class="resizable">
          </div>
          <div id="messagesColumn" class="resizable"></div>
          <div id="messageColumn" class="resizable"></div>
          </div>
          </div>
          </div>
          </div>
          </div>





          $(function() 
          $(".resizable").resizable(
          containment: ".card-body"
          );
          );

          .card-body 
          display: flex;


          .resizable
          height: 300px;
          border: 1px solid red;
          flex: 1 1 auto;

          <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
          <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

          <div class="container">
          <div class="row justify-content-center">
          <div class="col-md-12">
          <div class="card">
          <div class="card-header text-right"> __('Messages') </div>
          <div class="card-body ">
          <div id="usersColumn" class="resizable">
          </div>
          <div id="messagesColumn" class="resizable"></div>
          <div id="messageColumn" class="resizable"></div>
          </div>
          </div>
          </div>
          </div>
          </div>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 11:23









          ksavksav

          5,30921331




          5,30921331












          • It is good, but here is problem, moving the right middle border causes movement of middle left border. It is not good at all. If I name the columns as (1,2,3), moving 2 border to right must causes reducing 3 width and increasing 2 with. But it reduces 1 width as well.

            – No one
            Nov 13 '18 at 11:45

















          • It is good, but here is problem, moving the right middle border causes movement of middle left border. It is not good at all. If I name the columns as (1,2,3), moving 2 border to right must causes reducing 3 width and increasing 2 with. But it reduces 1 width as well.

            – No one
            Nov 13 '18 at 11:45
















          It is good, but here is problem, moving the right middle border causes movement of middle left border. It is not good at all. If I name the columns as (1,2,3), moving 2 border to right must causes reducing 3 width and increasing 2 with. But it reduces 1 width as well.

          – No one
          Nov 13 '18 at 11:45





          It is good, but here is problem, moving the right middle border causes movement of middle left border. It is not good at all. If I name the columns as (1,2,3), moving 2 border to right must causes reducing 3 width and increasing 2 with. But it reduces 1 width as well.

          – No one
          Nov 13 '18 at 11:45



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279702%2fjquery-ui-resiable-how-to-force-to-resize-within-the-parent%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo