使用bootstrap框架建立modal对话框,对话框并不能够正常显示(只会背景变暗,对话框完全不显示)
<!doctypehtml><htmllang="zh"><head><linkrel="shortcuticon"href="../img/logo_title.ico...
<!doctype html>
<html lang="zh">
<head>
<link rel="shortcut icon" href="../img/logo_title.ico">
<meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=Edge">
<link rel="stylesheet" href="../ex/bootstrap.min.css">
<title>Welcome to credIT!</title>
</head>
<body id="home">
<div class="container">
<div class="btn-toolbar">
<div class="pull-right">
<a href="#login" data-toggle="modal" class="btn">登陆</a>
<a href="../php/register.php" class="btn">注册</a>
</div>
</div>
</div>
<div class="container">
<div class="modal hide fade" id="login">
<div class="modal-head">
<a href="#" class="close" data-dismiss="modal">×</a>
<h4>用户登陆</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" name="username">用户名</label>
<div class="controls">
<input type="text">
</div>
</div>
<div class="control-group">
<label class="control-label" name="password">密码</label>
<div class="controls">
<input type="text">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">登陆</button>
</div>
</div>
</div>
<script src="../ex/jquery-2.1.1.min.js"></script>
<script src="../ex/bootstrap.min.js"></script>
</body>
</html> 展开
<html lang="zh">
<head>
<link rel="shortcut icon" href="../img/logo_title.ico">
<meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=Edge">
<link rel="stylesheet" href="../ex/bootstrap.min.css">
<title>Welcome to credIT!</title>
</head>
<body id="home">
<div class="container">
<div class="btn-toolbar">
<div class="pull-right">
<a href="#login" data-toggle="modal" class="btn">登陆</a>
<a href="../php/register.php" class="btn">注册</a>
</div>
</div>
</div>
<div class="container">
<div class="modal hide fade" id="login">
<div class="modal-head">
<a href="#" class="close" data-dismiss="modal">×</a>
<h4>用户登陆</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" name="username">用户名</label>
<div class="controls">
<input type="text">
</div>
</div>
<div class="control-group">
<label class="control-label" name="password">密码</label>
<div class="controls">
<input type="text">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">登陆</button>
</div>
</div>
</div>
<script src="../ex/jquery-2.1.1.min.js"></script>
<script src="../ex/bootstrap.min.js"></script>
</body>
</html> 展开
展开全部
<!doctype html>
<html lang="zh-cn">
<head>
<link rel="shortcut icon" href="../img/logo_title.ico">
<meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=Edge">
<link rel="stylesheet" href="../ex/bootstrap.min.css">
<title>Welcome to credIT!</title>
</head>
<body id="home">
<div class="container">
<div class="btn-toolbar">
<div class="pull-right">
<a href="#login" data-toggle="modal" class="btn">登陆</a>
<a href="../php/register.php" class="btn">注册</a>
</div>
</div>
</div>
<div class="container">
<div class="modal" id="login" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-head">
<a href="#" class="close" data-dismiss="modal">×</a>
<h4>用户登陆</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" name="username">用户名</label>
<div class="controls">
<input type="text">
</div>
</div>
<div class="control-group">
<label class="control-label" name="password">密码</label>
<div class="controls">
<input type="text">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">登陆</button>
</div>
</div>
</div>
</div>
</div>
<script src="../ex/jquery.js"></script>
<script src="../ex/bootstrap.min.js"></script>
</body>
</html>
modal默认隐藏需要采用aria-hidden='true'设定。其实modal已经执行了并且打开了,但是由于你添加hide类,所以整个modal就被隐藏了。另外你的整个modal框架缺少div.modal-dialog和div.modal-content两个元素包裹,否则样式比较难看的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询