jQuery tabs: panel covers tabs at 100% height

后端 未结 10 882
生来不讨喜
生来不讨喜 2021-01-11 13:15

I\'m trying to use the tabs widgets of jQuery-UI having panels content to extend to the whole available space.

Here\'s a simplified version of what I\'ve got so far:

10条回答
  •  心在旅途
    2021-01-11 13:40

    Instead of using your own CSS, use jQuery UI's built-in feature.

    var tabs = $("#tabs").tabs({heightStyle: "fill"});
    

    From the API documentation:

    heightStyle

    Type: String

    Default: "content"

    Controls the height of the tabs widget and each panel. Possible values:

    • "auto": All panels will be set to the height of the tallest panel.
    • "fill": Expand to the available height based on the tabs' parent height.
    • "content": Each panel will be only as tall as its content.

    Although you are right that a plain CSS solution would be very nice, since you are using JavaScript anyway to build the tab functionality, it will be best to use the existing capabilities of the script you already have.


    UPDATE:

    • See http://jsfiddle.net/MhEEH/45/ for the simplest full example. Note that it does not need any CSS position rules.

    • You need to use http://benalman.com/projects/jquery-resize-plugin/ (or similar) to watch the parent for size changes. Browsers only fire the resize event on the window itself by default, but this plugin extends support for that event to arbitrary elements being resized.

提交回复
热议问题