如何使Bootstrap面板可调整大小

6
如何允许拖拽面板底部以更改面板高度。
我在下面的代码中尝试了"resize: vertical" 样式,但它无法允许拖拽面板底部。
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
    <style>
        .panel-resizable {
            resize: vertical;
        }
    </style>
</head>
<body>

    <div class="panel panel-default">
        <div class="panel-body panel-resizable" style="height:80px">
        </div>
        <div class="panel-footer">Band1</div>
    </div>

    <div class="panel panel-default">
        <div class="panel-body panel-resizable">
        </div>
        <div class="panel-footer">Band2</div>
    </div>
</body>
</html>
3个回答

7
您需要添加overflow: auto;以使其正常工作。(如果您想隐藏溢出,只需将overflow: hidden;

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
    <style>
        .panel-resizable {
            resize: vertical;
          overflow: auto
        }
    </style>
</head>
<body>

    <div class="panel panel-default">
        <div class="panel-body panel-resizable" style="height:80px">
        </div>
        <div class="panel-footer">Band1</div>
    </div>

    <div class="panel panel-default">
        <div class="panel-body panel-resizable">
        </div>
        <div class="panel-footer">Band2</div>
    </div>
</body>
</html>


谢谢。如何通过拖动面板页脚在任何位置调整面板大小?在此示例中,只能使用面板内容右下角执行调整大小。 - Andrus
是的。整个面板底部可以用来调整大小。 - Andrus
1
它不允许更改高度小于 style="height:80px" 中指定的高度。如何修复此问题,以便面板内容可以调整为零高度? - Andrus
1
如果您想调整面板大小,则可以查看此链接 http://viralpatel.net/blogs/demo/resize-textarea-jquery-javascript.html - elreeda
如果指定了第二个面板的高度,则根本不允许调整大小。如果没有第二个面板高度,则不允许将内容高度调整为0。我在http://stackoverflow.com/questions/34601106/how-to-allow-to-resize-panel-height-to-0中发布了它。 - Andrus

5

这个代码片段不允许减小面板内容的高度。在Internet Explorer中,它根本不允许调整大小。如何解决这个问题?我已经在http://stackoverflow.com/questions/34601106/how-to-allow-to-resize-panel-content-height-to-0?lq=1上发布了一个单独的问题。 - Andrus

0

这个代码片段不允许减小面板高度。在Internet Explorer中,它不允许任何调整大小。如何解决这个问题? - Andrus
Internet Explorer不支持resize属性。您必须使用类似jQueryUI的东西来实现这个效果在任何版本的IE中,包括Edge在内的当前版本。 - Jason Conville

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接