2013-06-18 60 views
4

我使用引導模式來顯示圖像。製作Twitter Bootstrap模態窗口較大

我該如何簡單地使Twitter Bootstrap模態窗口變大?

我使用代碼從(related)問題:

$('#myModal').modal({ 
     backdrop: true, 
     keyboard: true, 
     show: false 
    }).css({ 
     // make width 90% of screen 
     'width': function() { 
      return ($(document).width() * .9) + 'px'; 
     }, 
     // center model 
     'margin-left': function() { 
      return -($(this).width()/2); 
     } 
}); 

但這裏的結果:

我必須滾動下來。如何保持圖像比例並在沒有滾動條的情況下顯示它?

+2

完全不相關,但我不喜歡camelcased css選擇器。但這只是一個品味問題:) – nathanvda

+0

我也是。我喜歡用破折號將它們分開。我剛剛從源代碼複製它,這就是所有:) – lexeme

回答

4

當我們表明自舉模式的圖像,我們用下面的CSS:

#myModal { 
    max-height: 80%; 
    overflow-y: auto; 

    .modal-body { 
    max-height: none; 
    text-align: center; 
    } 
} 

然後就去做

$('#myModal').modal("show"); 

的關鍵是在.modal-bodymax-height設置爲none

+0

包含的「CSS」代碼看起來像LESS而不是CSS。 – nickdos

+0

對不起,這是真的:我在大多數項目中使用sass(rails開發人員在這裏)。 – nathanvda