2013-09-28 62 views
1

我試圖通過單擊按鈕來顯示模式對話框。我正在嘗試使用引導程序。我的按鈕沒有正確設置(它應該是藍色的,但它只是一個鏈接),點擊鏈接時不會出現模式對話框。當我點擊按鈕時,屏幕會變成灰色。該模式的示例代碼來自引導網站。我從CDN加載所有資源。這似乎並不困難。無法獲取簡單的twitter引導模式對話框彈出

http://jschr.github.io/bootstrap-modal/bs3.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Untitled Document</title> 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> 
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> 
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen"> 

</head> 

<body> 

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

<!-- Modal --> 
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
    <h3 id="myModalLabel">Modal header</h3> 
    </div> 
    <div class="modal-body"> 
    <p>One fine body…</p> 
    </div> 
    <div class="modal-footer"> 
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> 
    <button class="btn btn-primary">Save changes</button> 
    </div> 
</div> 

</body> 
</html> 

回答

4
  1. 按鈕的默認類型=> BTN-默認

    <a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Launch demo modal</a> 
    
  2. 忘了把2周的div '模式,對話' 和 '模式內容'

    <div class="modal-dialog"> 
        <div class="modal-content"> 
    
  3. 刪除隱藏的DIV 'myModal'

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

http://jsfiddle.net/32fWL/1/

+0

是的,它修復了它。 – spock99

1

爲按鈕添加BTN-主類:class="btn btn-primary"

爲模態,從類中刪除hide

+0

這顯示模式,但它是整個屏幕的寬度,並沒有背景。我發現問題是互聯網上的很多示例都是針對版本 spock99