【问题标题】:Modal box doesn't show completely模态框未完全显示
【发布时间】:2013-06-25 14:46:25
【问题描述】:

我正在使用Bootstrap 来布局我的页面并在某些地方使用模态框。 现在,当我单击一个链接时,它会打开一个确认模式框,至少它应该是这样。 但是,如果窗口太宽(~ >700px),它只会显示模态框的一部分:

如果窗口足够小(可能与响应能力有关),它将显示整个屏幕。

这是我如何实现模态框的。

<a class="confirm-delete" data-id=someValue role="button"><i class="icon-trash"></i></a>

$('.confirm-delete').click(function(e) {                
    e.preventDefault();                                 
    var id = $(this).data('id');                        
    $('#deleteConfirmation').data('id', id).modal('show');                                                              
});

$('#deleteConfirmation').bind('show', function() {
    var id = $(this).data('id');                        
});

这是我包含的部分 CSS 和脚本:

<link rel="stylesheet" href="${cherrypy.url('/asset/css/bootstrap.css')}" media="screen" />
<link rel="stylesheet" href="${cherrypy.url('/asset/css/glyphicons.css')}" media="screen" />
<link rel="stylesheet" href="${cherrypy.url('/asset/css/datepicker.css')}" media="screen" />
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<link rel="stylesheet" href="${cherrypy.url('/asset/css/modified-bootstrap-responsive.min.css')}" media="screen" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" type="text/css" />

任何想法可能是不完全显示模态框的原因是什么?抱歉,我无法在小提琴中重现该问题,也无法提供实时站点。

<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>                              
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js" type="text/javascript"></script>                        
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>                      
<script src="${cherrypy.url('/asset/js/bootstrap-datepicker.js')}"></script> 

编辑: 我在 HTML 页面上没有太多内容。只需一个按钮和确认框。

这是页面的结构:

<%! import cherrypy %>
<!DOCTYPE html>
<html>
<head>
    <%include file="header.mako"/>
</head>
    <!-- Piwik Tracking Code -->
<body>
<%include file="navigation.mako"/>
    <div class="container">
        <p>
            ${self.body()}
        </p>
    </div>
  </body>
</html>

header.mako 由我在上面发布的样式表组成,${self.body()} 是确认对话框和 JS(上面发布):

<div class="modal hide fade" id="deleteConfirmation" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button
        <h3>Confirmation</h3>
    </div>
    <div class="modal-body"><p class="error-text">Sure?</p>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button><a href="${cherrypy.url('email=')}" class="btn btn-danger">Delete</a>
    </div>
</div>

【问题讨论】:

  • 你能张贴一些 html 的正文吗?特别是围绕您的内容的包装器。试图重现,它可能与类有关。
  • @JasonM 我更新了我的初始帖子。不过,内容不多。我猜问题出在 CSS 文件的某个地方...
  • 我猜它在修改后的响应式引导文件中的某个地方。如果你不包括它,它会起作用还是你会遇到同样的问题?
  • @JasonM 好的,感谢您的建议,我发现罪魁祸首是 bootstrap.css 文件。我什至不知道为什么它还在那里,因为我使用的是CDN'sbootstrap-combined-min.css。真的不知道是什么导致了问题,但谢谢!

标签: javascript css twitter-bootstrap modal-dialog cherrypy


【解决方案1】:

看起来像这样一行:

<link rel="stylesheet" href="${cherrypy.url('/asset/css/bootstrap.css')}" media="screen" />

与来自 cdn 的组合引导文件冲突:

<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">

只需删除来自资产的 bootstrap.css 链接,您应该就可以了。

注意:这是来自 cmets - 只是放在这里以防其他人发生这种情况

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-24
    • 2011-11-17
    • 1970-01-01
    • 1970-01-01
    • 2021-10-18
    • 2010-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多