Twitter bootstrap 移动设备中的隐藏引导模式

Twitter bootstrap 移动设备中的隐藏引导模式,twitter-bootstrap,mobile,bootstrap-modal,Twitter Bootstrap,Mobile,Bootstrap Modal,如何在移动设备中隐藏引导模式。我尝试使用修饰符类,如hidden xs hidden sm,但失败了。模态将转到底部页面,使顶部页面无法访问 这是我的密码: <div class="modal fade hidden-xs hidden-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="margin-top:1em;"> <

如何在移动设备中隐藏引导模式。我尝试使用修饰符类,如hidden xs hidden sm,但失败了。模态将转到底部页面,使顶部页面无法访问

这是我的密码:

<div class="modal fade hidden-xs hidden-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="margin-top:1em;">
  <div class="modal-dialog">
   <div class="modal-content">
     <div class="modal-body">
       <img src="banner.jpg" height="388" width="558" alt="" class="img-rounded">
     </div>
    <div class="modal-footer" style="border:0">
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
   </div>
  </div>
</div>


但是,它们也失败了。

您的媒体查询被jQuery覆盖。用jQuery试试

大概是这样的:

$('#myModal').on('shown.bs.modal', function () {
    var width = $(window).width();  
    if(width < 480){
        $(this).hide(); 
    }
});
$('myModal').on('show.bs.modal',function(){
变量宽度=$(窗口).width();
如果(宽度<480){
$(this.hide();
}
});

正如您所说,您的css不起作用,我建议您使用jquery方法,只需在模式html代码
之前添加此内容,并使用以下脚本

if($('.check-width').width() == 500){
   $('#myModal').modal('hide'); 

}
else{

}

上面Danko的回答仍然在我的页面上留下了黑暗的覆盖层(尽管没有出现模态),但这对我来说是有效的:

    $('#myModal').on('shown.bs.modal', function () {
        var width = $(window).width();  
        if(width < 768){
            $('#myModal').modal('hide') 
        }
    });
$('myModal').on('show.bs.modal',function(){
变量宽度=$(窗口).width();
如果(宽度<768){
$('#myModal').modal('hide'))
}
});

这个媒体查询帮了我的忙

    @media(max-width:810px){
    #mymodal{
        display: none !important;
    }

    .modal-backdrop{
        display: none !important;;
    }
}

我先在桌面上试了一下,但模式显示失败。你删除了你的旧css行了吗?是的,我删除了。这是Bootstrap手册中的示例:$(function(){$(“#myModal”).modal();});“您的代码现在可以工作了,”我修改了.model类,在我的样式中,它阻止此代码工作。谢谢
    $('#myModal').on('shown.bs.modal', function () {
        var width = $(window).width();  
        if(width < 768){
            $('#myModal').modal('hide') 
        }
    });
    @media(max-width:810px){
    #mymodal{
        display: none !important;
    }

    .modal-backdrop{
        display: none !important;;
    }
}