csstwitter-bootstrap

Use parent div size for Bootstrap responsive grid system


I need to use bootstrap 12 columns grid to get a responsive form based on the parent div's size.

As an exemple, whatever the size of the screen, the content need to see the div A's width and base the bootstrap's responsive design on that width.

My goal is to base my responsive design on the size of a modal window (in dhtmlx). If the user resize the modal window, the row should follow the rules (e.g. col-xs-12, col-sm-6, etc, but based on the size of the modal window, not the screen).

This fiddle show a modal window with some bootstrap form inside. I need the form to be responsive to the size of the modal form, not the screen size.

class="col-xs-12 col-sm-6"

Solution

  • As @makshh mentionned in the comment, it does not seem to be possible to do this right now. The only way I found is from another stack overflow question by @tsdexter:

    $(document).ready(function(){
      $('.somecontainer').on('resize',function(){
        if ($('.somecontainer').width() < 640) {
            $('.somecontainer').addClass('m');
        } else {
            $('.somecontainer').removeClass('m');
        }
      });
    });