cpw*_*cpw 11 jquery twitter-bootstrap
我使用bootstrap模式插件.但是模态对话框没有显示在中心.为什么?我的错?
http://dl.dropbox.com/u/573972/stackoverflow/bootstrap/modal.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>test</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS-->
<link rel="stylesheet" href="bootstrap.min.css">
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7/jquery.min.js'></script>
</head>
<body>
<div id="login" class="modal">
<div class="modal-header">
<h3>Login to Room fuga</h3>
</div>
<div class="modal-body">
hogehoge
</div>
</div>
<script src="bootstrap.min.js">
</script>
<script>
$('#login').modal();
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
小智 18
我找到了解决此问题的方法:
$('#YourModal').modal().css(
{
'margin-top': function () {
return -($(this).height() / 2);
}
})
Run Code Online (Sandbox Code Playgroud)
资料来源:https://github.com/twitter/bootstrap/issues/374
ner*_*ess 10
如果你的twitter bootstrap模态对话框没有水平居中,你可以通过css解决这个问题.
只需给模态对话框一个负的左边距,就像它的宽度一样,例如:
.modalDialogBlabla {
margin: 0 0 0 -250px;
width: 500px;
}
Run Code Online (Sandbox Code Playgroud)
捕获show事件.modal然后计算新位置:
$('body').on('show', '.modal', function(){
$(this).css({'margin-top':($(window).height()-$(this).height())/2,'top':'0'});
});?
Run Code Online (Sandbox Code Playgroud)
演示:http://jsfiddle.net/sonic1980/b2EHU/
| 归档时间: |
|
| 查看次数: |
18202 次 |
| 最近记录: |