css3實現的使用者登入表單程式碼例項

admin發表於2017-02-25

分享一段簡單的程式碼例項,它實現了簡單的表單使用者登入效果。

並且具有一些css3實現的效果,比如滑鼠點選文字框底部會出現動畫條效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css" media="screen">
body {
  padding: 0px;
  margin: 0px;
}
ul,li,a {
  padding: 0px;
  margin: 0px;
  list-style: none;
}
.sign {
  max-width: 20rem;
  min-width: 15rem;
  margin: 2.4rem auto;
  color: #333;
}
.sign .section {
  background-color: #fff;
  border: 1px solid #ececec;
  border-radius: 2px;
  padding: 2rem 2.5rem;
}
.sign .section.form {
  width: 100%;
  height: 15rem;
}
.form-item {
  position: relative;
  width: 100%;
  height: auto;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #ececec;
}
.form-item:first-child {
  margin-bottom: 1rem;
}
.form-item:last-child {
  border: none;
}
.form-item input {
  margin: 0.5rem 0.4rem;
  font-size: 0.73rem;
  border: none;
  outline: none;
  box-shadow: none;
  -webkit-box-shadow: none;
  width: calc(100% - 70px);
}
.form-item .bot-bar {
  position: relative;
  height: 1px;
  width: 100%;
}
.bot-bar:before {
  position: absolute;
  bottom: -1px;
  left: 50%;
  content: "";
  height: 1px;
  width: 0px;
  background-color: #1B76C5;
  box-shadow: 1px 1px 3px rgba(255, 255, 255, 0.3);
  transition: width ease-in-out .35s;
  -moz-transition: width ease-in-out .35s;
  -o-transition: width ease-in-out .35s;
  -webkit-transition: width ease-in-out .35s;
}
.bot-bar:after {
  position: absolute;
  bottom: -1px;
  right: 50%;
  content: "";
  height: 1px;
  width: 0px;
  background-color: #1B76C5;
  transition: width ease-in-out .35s;
  -moz-transition: width ease-in-out .35s;
  -o-transition: width ease-in-out .35s;
  -webkit-transition: width ease-in-out .35s;
}
.form-item h2 {
  text-align: center;
  color: #5474db;
}
.form-item input:focus ~ .bot-bar:before {
  width: 50%;
}
.form-item input:focus ~ .bot-bar:after {
  width: 50%;
}
.form-item .icon {
  margin: 0.5rem 0.5rem;
  color: #5474db;
}
.form-item .info {
  color: red;
  position: absolute;
  right: 0px;
  font-size: 0.71rem;
}
.form-submit {
  position: relative;
  text-align: center;
  background-color: #617fde;
  border-radius: 5px;
  overflow: hidden;
  padding: 0.3rem;
  color: aliceblue;
  letter-spacing: 0.1rem;
  cursor: pointer;
  line-height: 1.6rem;
  font-size: 0.7rem;
  height: 1.6rem;
  transition: all ease-in-out .35s;
  -moz-transition: all ease-in-out .35s;
  -o-transition: all ease-in-out .35s;
  -webkit-transition: all ease-in-out .35s;
}
.form-submit:hover {
  font-size: 0.9rem;
  background-color: #5474db;
}
.icon-mobile-phone:before {
  font-size: 2rem;
}
.icon-user-md:before {
  font-size: 1.2rem;
}
.form-submit:before {
  font-size: 0.9rem;
  position: absolute;
  top: 0px;
  left: 0px;
  content: attr(data-txt);
  background-color: #617fde;
  width: 100%;
  line-height: 2.2rem;
  letter-spacing: 0.1rem;
  overflow: hidden;
  text-align: center;
  height: 1.1rem;
  transition: top ease-in-out .35s;
  -moz-transition: top ease-in-out .35s;
  -o-transition: top ease-in-out .35s;
  -webkit-transition: top ease-in-out .35s;
}
.form-submit:hover:before {
  top: -1.1rem;
}
.form-submit:after {
  font-size: 0.9rem;
  position: absolute;
  bottom: 0px;
  left: 0px;
  content: attr(data-txt);
  background-color: #617fde;
  width: 100%;
  line-height: 1px;
  letter-spacing: 0.1rem;
  overflow: hidden;
  text-align: center;
  height: 1.1rem;
  transition: bottom ease-in-out .35s;
  -moz-transition: bottom ease-in-out .35s;
  -o-transition: bottom ease-in-out .35s;
  -webkit-transition: bottom ease-in-out .35s;
}
.form-submit:hover:after {
  bottom: -1.1rem;
}
</style>
</head>
<body>
  <div class="sign">
    <div class="section">
      <form id="form">
        <div class="form-item">
          <h2>登入主題</h2>
        </div>
        <div class="form-item">
          <i class="icon-user-md icon"></i>
          <input v-model="user.name" type="text" class="form-input" name="name" placeholder="使用者姓名">
          <div class="bot-bar"></div>
 
        </div>
        <div class="form-item">
          <i class="icon-mobile-phone icon"></i>
          <input v-model="user.phone"  type="text" class="form-input" name="phone" placeholder="電話號碼">
          <div class="bot-bar"></div>
 
        </div>
        <div class="form-item">
          <i class="icon-envelope icon"></i>
          <input v-model="user.email"  type="text" class="form-input" name="email" placeholder="電子郵箱">
          <div class="bot-bar"></div>
 
        </div>
        <div class="form-item">
          <div class="form-submit" data-txt="Login"> Login </div>
        </div>
      </form>
    </div>
  </div>
</body>
</html>

相關文章