How can I change the default width of a Twitter Bootstrap modal box?

后端 未结 30 2618
醉酒成梦
醉酒成梦 2020-11-27 08:38

I tried the following:

   
30条回答
  •  [愿得一人]
    2020-11-27 09:16

    Less-based solution (no js) for Bootstrap 2:

    .modal-width(@modalWidth) {
        width: @modalWidth;
        margin-left: -@modalWidth/2;
    
        @media (max-width: @modalWidth) {
            position: fixed;
            top:   20px;
            left:  20px;
            right: 20px;
            width: auto;
            margin: 0;
            &.fade  { top: -100px; }
            &.fade.in { top: 20px; }
        }
    }
    

    Then wherever you want to specify a modal width:

    #myModal {
        .modal-width(700px);
    }
    

提交回复
热议问题