创建web项目
引入bootstrap:
创建login页面引入bootstrap:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<!--引入bootstrap的css-->
<link rel="stylesheet" href="../static/css/bootstrap.min.css">
<!--引入jQuery的文件-->
<script src="../static/jq/jquery-3.6.0.js"></script>
<!--引入bootstrap的js文件-->
<script src="../static/js/bootstrap.min.js"></script>
</head>
<body>
</body>
</html>
刷新页面F12在NetWork查看是否引入成功:
<!--用户标题-->
<div class="row" style="margin-top: 70px">
<!--偏移3分占6分-->
<div class="col-sm-6 col-sm-offset-3">
<h1 class="text-center">用户登录</h1>
</div>
</div>
<!--用户表单-->
<div class="row">
<!--偏移3分占6分-->
<div class="col-sm-6 col-sm-offset-3">
<!--表单-->
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" id="exampleInputFile">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
修改表单:
<!--用户表单-->
<div class="row">
<!--偏移3分占6分-->
<div class="col-sm-6 col-sm-offset-3">
<!--表单-->
<form>
<div class="form-group">
<label for="name">用户名</label>
<input type="email" class="form-control" id="name" placeholder="请输入用户名">
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" class="form-control" id="password" placeholder="请输入密码">
</div>
<div class="form-group">
<label for="code">验证码</label>
<div>
<input type="text" class="form-control" style="width: 70%; height:55px;float: left;" id="code" placeholder="请输入验证码">
<img src="../static/imgs/22.png" style="float:right;width: 220px;height: 55px">
</div>
</div>
<div class="clearfix"></div>
<button type="submit" class="btn btn-danger" style="margin-top: 10px;float:left;width: 65%">登录</button>
<button type="submit" class="btn btn-info" style="margin-top: 10px;float: right;width: 25%">登录</button>
</form>
</div>
</div>
全部登录代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<!--引入bootstrap的css-->
<link rel="stylesheet" href="../static/css/bootstrap.min.css">
<!--引入jQuery的文件-->
<script src="../static/jq/jquery-3.6.0.js"></script>
<!--引入bootstrap的js文件-->
<script src="../static/js/bootstrap.min.js"></script>
<style>
.form-control{
height: 45px;
}
</style>
</head>
<body>
<!--用户标题-->
<div class="row" style="margin-top: 70px">
<!--偏移3分占6分-->
<div class="col-sm-6 col-sm-offset-3">
<h1 class="text-center">用户登录</h1>
</div>
</div>
<!--用户表单-->
<div class="row">
<!--偏移3分占6分-->
<div class="col-sm-6 col-sm-offset-3">
<!--表单-->
<form>
<div class="form-group">
<label for="name">用户名</label>
<input type="email" class="form-control" id="name" placeholder="请输入用户名">
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" class="form-control" id="password" placeholder="请输入密码">
</div>
<div class="form-group">
<label for="code">验证码</label>
<div>
<input type="text" class="form-control" style="width: 70%; height:55px;float: left;" id="code" placeholder="请输入验证码">
<img src="../static/imgs/22.png" style="float:right;width: 220px;height: 55px">
</div>
</div>
<div class="clearfix"></div>
<button type="submit" class="btn btn-danger" style="margin-top: 10px;float:left;width: 65%">登录</button>
<button type="submit" class="btn btn-info" style="margin-top: 10px;float: right;width: 25%">登录</button>
</form>
</div>
</div>
</body>
</html>