我该如何在移动端隐藏Bootstrap模态框?我尝试使用修饰类例如 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>
由于hidden-xs 和 hidden-sm 失效,我尝试修改我的CSS:
@media only screen and (max-device-width: 480px){
#myModal{display: none;}
}
或者
@media only screen and (max-device-width: 480px){
.modal{display: none;}
}
但是,它们也有失败的情况。
$(function() { $("#myModal").modal(); });
- sianipard