简体   繁体   English

Bootstrap 2 - 设置对话框/模态位置

[英]Bootstrap 2 - set dialog/modal position

I've found one way to do this: 我找到了一种方法:

use margins to control dialog position so margin: -335px 0 0 -280px ; 使用边距来控制对话位置,使margin: -335px 0 0 -280px ;

setting the width you must reset the margins width: 900px; margin: -250px 0 0 -450px; 设置宽度必须重置边距width: 900px; margin: -250px 0 0 -450px; width: 900px; margin: -250px 0 0 -450px;

to set the height use max-height max-height: 800px; 设置高度使用max-height max-height: 800px; based on 基于

http://www.revillwebdesign.com/change-the-height-width-and-position-of-a-modal-in-twitter-bootstrap/ http://www.revillwebdesign.com/change-the-height-width-and-position-of-a-modal-in-twitter-bootstrap/

Is there a better way to do this? 有一个更好的方法吗? Using this or another approach, is there a way to only have the dialog slide down to top:0px and stay there until dismissed? 使用这种或另一种方法,有没有办法让对话框滑到top:0px并保持在那里直到被解雇?

Using the first margin settings I mentioned does this but obviously as soon as the browser is resized it will get pushed out of view. 使用我提到的第一个边距设置可以做到这一点但显然一旦浏览器调整大小,它就会被推出视图。

Simply override the CSS position, eg 只需覆盖CSS位置,例如

.modal, .modal.fade.in {
    top: 0; /* was 10% */
}

Note, this is with Bootstrap 2.2.2 . 注意,这是使用Bootstrap 2.2.2 The only margin is a negative left margin that is half the width of the modal (centres the modal horizontally). 唯一的余量是负左边距,是模态宽度的一半(水平模态中心)。 No top margins are required. 不需要最高利润。

jsFiddle example here - http://jsfiddle.net/uuwAn/1/ 这里的jsFiddle示例 - http://jsfiddle.net/uuwAn/1/

You can modify the CSS at your end to archive this behavior. 您可以修改最后的CSS以存档此行为。

.modal-body {
    max-height: 350px;
    -webkit-overflow-scrolling: touch;
}

@media screen and (max-height: 450px), (max-height: 450px) {
    .modal-body {
        max-height: 130px;
    }

}

Now its will work well on the mobile devices. 现在它将在移动设备上运行良好。 NOTE: done by using Media query of CSS . 注意:使用CSS媒体查询完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM