2013-07-10 64 views
22

我被卡住了。鑑於Bootstrap 3.0即將發佈,我決定爲它開發一個新項目。事情目前進展順利,但對於我的生活,我無法弄清楚如何在Bootstrap 3.0中做Modal對話框。Bootstrap 3.0 Modal

有沒有人有一個簡單的例子?

+1

有Bootstrap 3模式的信息在這裏:https://github.com/twitter/bootstrap/pull/6342 - 但它應該基本上工作相同的2.x模式。你試過什麼了? – ZimSystem

+2

這是一個工作演示http://www.bootply.com/67046爲BS3模式 – ZimSystem

回答

51

你可以嘗試建立文檔:Compile Twitter bootstrap 3 docs (How to)?所以也http://bassjobsen.weblogs.fm/explore-and-install-twitter-bootstrap-3/從文檔:

<!-- Button trigger modal --> 
    <a data-toggle="modal" href="#myModal" class="btn btn-primary btn-lg">Launch demo modal</a> 

    <!-- Modal --> 
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
      <h4 class="modal-title">Modal title</h4> 
     </div> 
     <div class="modal-body"> 
      ... 
     </div> 
     <div class="modal-footer"> 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
      <button type="button" class="btn btn-primary">Save changes</button> 
     </div> 
     </div><!-- /.modal-content --> 
    </div><!-- /.modal-dialog --> 
    </div><!-- /.modal --> 
+0

這工作。簡單。不知道我做錯了什麼。我只是把所有東西都挖出來,並開始新鮮。謝謝! – Eric

+0

我也遇到了模式方面的問題,我正在從網站上的演示中修剪。按下「在標題欄中啓動dmeo模式鏈接」。http://jsfiddle.net/RMgZV/2/ – andyczerwonka

+2

@andyczerwonka將模態的html複製到不在導航欄內的某處。請參閱:http://jsfiddle.net/ kcS2N/1 / –

0

我一直在對抗同樣的問題,由於這次談話,我發現我錯了。當使用TwitterBootstrap3,你需要以下東西:

A鍵觸發

<a data-toggle="modal" 
    href="#myModal" 
    class="btn btn-primary btn-lg" 
>Launch demo modal</a> 

的這種minimun結構的DIV:

<div class="modal fade" 
    id="myModal" 
    tabindex="-1" 
    role="dialog" 
    aria-labelledby="myModalLabel" 
    aria-hidden="true" 
> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
      <!-- blah blah content here --> 
     </div> 
    </div> 
</div> 

知道這是很重要的,如果你不不放置模式對話框和模型內容,模式窗口不會正常打開