Bootstrap模式看起来不像弹出窗口

时间:2016-07-21 11:45:14

标签: html twitter-bootstrap bootstrap-modal

我使用jquery创建了一个数据表。它的第二列有帐号。当用户点击帐号时,页面上会出现一个模态。像下面的图像。

enter image description here

但是我的模态看起来不像弹出窗口。它看起来像这样: enter image description here

以下是我的代码:

<div id="select-account-expanded" style="display:none">

        <!-- Begin of select-statement modal -->
        <div class="modal fade" id="select-statement-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display:none;">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="select-statement-title">Select Statement(s)</h4>
              </div>
              <div class="modal-body">
                  <table id="statement-table-modal">
                          <thead>
                                <tr>
                                    <th>
                                    <input type="checkbox" id="select-all-statement" value="" /><label for="select-all-statement"></label>
                                    </th>
                                    <th>Statement</th>
                                    <th>Due Date</th>
                                    <th>Total Due</th>
                                    <th>Payment Amount</th>
                                </tr>
                                </thead>
                       </table>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-primary">Continue</button>
              </div>
            </div>
          </div>
        </div> <!-- End of modal -->
              <table id="multiple-account-table">
                  <thead>
                        <tr class="border-class">
                            <th class="black white-active-bg pad-bottom-0-5">
                            <input type="checkbox" id="select-all-statement" value="" /><label for="select-all-statement"></label>
                            </th>
                            <th>Account Number</th>
                            <th>Account Name</th>
                            <th>Alias</th>
                            <th>Due Date</th>
                            <th>Total Due</th>
                            <th>Payment Amount</th>
                        </tr>
                        </thead>
                        <tbody>
                             <tr>
                                 <td>input type="checkbox" id="statement" value="" /><label for="select-all-statement"></label></td>
                                 <td><span id="launch-modal">1000</span></td>
                                 <td>Alwar</td>
                                 <td>07/07/2015</td>
                                 <td>$1000.00</td>
                                 <td><input type="textbox" value=""/></td>
                              </tr>

                         </tbody>
               </table>
    </div>

有一个链接,通过点击该链接,会出现模态。以下是相同的javascript代码:

$(document).on('click', '#launch-modal', function () {
    $("#select-statement-modal").modal();
});

有什么建议吗?

更新 我发现了自己的错误。导入bootstrap.min.css文件时出现了一些错误。现在我已经纠正了。它开始工作正常。

2 个答案:

答案 0 :(得分:1)

它会正常运行尝试。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Bootstrap 3 Modals</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#myModal").modal('show');
	});
</script>
</head>
<body>
<div id="myModal" class="modal fade">
    <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> -->
               
				 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="select-statement-title">Select Statement(s)</h4>
            </div>
            <div class="modal-body">
              <table class="table table-bordered">
			   <thead>
    <tr>
        <th data-field="id">Item ID</th>
        <th data-field="name">Item Name</th>
        <th data-field="price">Item Price</th>
    </tr>
    </thead>
	<tbody>
    <tr>
        <td><input type="checkbox" onclick="getRow(this)"  /></td>
        <td>aaa</td>
        <td>bbb</td>
    </tr>
    <tr>
        <td><input type="checkbox" onclick="getRow(this)" /></td>
        <td>ccc</td>
        <td>ddd</td>
    </tr>
    <tr>
        <td><input type="checkbox" onclick="getRow(this)" /></td>
        <td>eee</td>
        <td>fff</td>
    </tr>
	<tbody>
</table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">Continue</button>
               
            </div>
        </div>
    </div>
</div>
</body>
</html>                                		

答案 1 :(得分:0)

花了几个小时调试同样的问题,我想补充一个更详细的答案。对我来说问题是我错误地加载了可选的bootstrap主题css而不是核心css(在Wordpress上):

wp_enqueue_style( 'bootstrap_css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css',array(),'3.3.7' );

我应该加载这个:

wp_enqueue_style( 'bootstrap_css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',array(),'3.3.7' );

(参见两者之间URL的差异)。