jQuery UI and Splitter

前端 未结 4 1407
栀梦
栀梦 2021-02-08 13:45

Using jQuery UI, how can I use a Splitter kind of feature like the one at http://methvin.com/splitter/3csplitter.html?

I am asking this as I need 2 things to be impleme

4条回答
  •  [愿得一人]
    2021-02-08 14:22

    Here is an example on how to create the splitter using jQuery UI:

    HTML:

    Script:

    $(function () 
    {
        $(".resizable1").resizable(
        {
            autoHide: true,
            handles: 'e',
            resize: function(e, ui) 
            {
                var parent = ui.element.parent();
                var remainingSpace = parent.width() - ui.element.outerWidth(),
                    divTwo = ui.element.next(),
                    divTwoWidth = (remainingSpace - (divTwo.outerWidth() - divTwo.width()))/parent.width()*100+"%";
                    divTwo.width(divTwoWidth);
            },
            stop: function(e, ui) 
            {
                var parent = ui.element.parent();
                ui.element.css(
                {
                    width: ui.element.width()/parent.width()*100+"%",
                });
            }
        });
    });
    

    This is a popular script. I've added little modifications for the fluid layout.

    jsFiddle example

提交回复
热议问题