用bootstrap做一個背景可輪轉的登錄界面
一、總結
一句話總結:用css3的動畫的 @keyframes 規則,制作輪轉圖。
1、用bootstrap做一個背景可輪轉的登錄界面?
a、動畫部分用的animation動畫,動態的切換背景圖
@keyframes myfirst { 0% {background:url("../img/1.jpg");} 34% {background:url("../img/2.jpg");} 67% {background:url("../img/3.jpg");} 100% {background:url("../img/1.jpg");} }
b、樣式布置用的網格系統,offset-3實現居中
水平居中利用bootstrap的網格系統,offset-3向右移動3格.(網格系統中默認12個格)
<div class="form-horizontal col-md-offset-3" id="login_form">
二、用bootstrap做登入注冊頁面
效果圖(由於2M的限制效果圖大小不一致)
html代碼
水平居中利用bootstrap的網格系統,offset-3向右移動3格.(網格系統中默認12個格)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>login</title>
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div class="form row">
<div class="form-horizontal col-md-offset-3" id="login_form">
<h3 class="form-title">LOGIN</h3>
<div class="col-md-9">
<div class="form-group">
<i class="fa fa-user fa-lg"></i>
<input class="form-control required" type="text" placeholder="Username" id="username" name="username" autofocus="autofocus" maxlength="20"/>
</div>
<div class="form-group">
<i class="fa fa-lock fa-lg"></i>
<input class="form-control required" type="password" placeholder="Password" id="password" name="password" maxlength="8"/>
</div>
<div class="form-group">
<label class="checkbox">
<input type="checkbox" name="remember" value="1"/>記住我
</label>
</div>
<div class="form-group col-md-offset-9">
<button type="submit" class="btn btn-success pull-right" name="submit">登錄</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
css部分
用css3的動畫的 @keyframes 規則,制作輪轉圖。
body{ background: url("../img/1.jpg"); animation-name:myfirst; animation-duration:12s; /*變換時間*/ animation-delay:2s; /*動畫開始時間*/ animation-iteration-count:infinite; /*下一周期循環播放*/ animation-play-state:running; /*動畫開始運行*/ }
@keyframes myfirst {
0% {background:url("../img/1.jpg");}
34% {background:url("../img/2.jpg");}
67% {background:url("../img/3.jpg");}
100% {background:url("../img/1.jpg");}
}
.form{background: rgba(255,255,255,0.2);width:400px;margin:120px auto;}
/*陰影*/
.fa{display: inline-block;top: 27px;left: 6px;position: relative;color: #ccc;}
input[type="text"],input[type="password"]{padding-left:26px;}
.checkbox{padding-left:21px;}