1

I'm using Bootstrap v3.0.1

When a modal is activated I get a scroll bar appear. In some situations it even shifts the content over to the left, completely ruining the effect.

I've tried setting the main body so that it always has a scroll bar, but then I get two.

Here is an example.

http://nu11.co.uk/modal.html

4

1 回答 1

1

.modal类具有以下 CSS 规则:

.modal {
    position: fixed;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;
    z-index: 1040;
    display: none;
    overflow-x: auto;
    overflow-y: scroll;
 }

滚动条是因为overflow-xoverflow-y行。

假设你从 CDN 调用 bootstrap.css,如果你在链接 bootsrap.css 后在页面的 head 标签中 hack 这条规则,滚动条就会消失:

<head>
    .
    .
    .
    <link href="/dist/css/bootstrap.css" rel="stylesheet">
    .
    .
    .
    <style>
        .modal {
            overflow-x: hidden;
            overflow-y: hidden;
        }
    </style>
    .
    .
    .
</head>       
于 2013-11-01T20:44:49.510 回答