CSS3简约紫色渐变背景登录页面实现

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS3简约紫色渐变背景登录页面实现</title>
  <style>
    body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
}

.container {
  height: 100%;
  background: linear-gradient(to right, #fbc2eb, #a6c1ee);
}

.login-form {
  background-color: #fff;
  width: 350px;
  height: 500px;
  border-radius: 15px;

  /* 定位到中心 */
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.text {
  /* height: 80px; */
  /* 标题Login的样式 */
  font-size: 30px;
  font-weight: 700;
  /* 800px; */

  text-align: center;
  line-height: 80px;

  margin-top: 40px;
}

.form-item,
.btn,
.other {
  margin: 40px auto;
  width: 90%;
}

input {
  width: 80%;
  margin-top: 20px;
  padding: 10px;
  /* placeholder变更为大写字体 */
  text-transform: uppercase;
  /* 边框效果 */
  border: 0;
  outline: none;
  border-bottom: 1px solid #fbc2eb;
}

input::placeholder {
  font-weight: bold;
  color: #acb7c9;
}

input:focus {
  /* 当输入框获取焦点时的效果 */
  /* box-shadow: 0px 0px 5px #fbc2eb;
  border-bottom: 1px solid #fff; */
  animation: bBottom 2s infinite;
}

@keyframes bBottom {
  50% {
    border-bottom: 1px solid #a6c1ee;
  }
}

.btn {
  height: 40px;
  line-height: 40px;
  /* 字体 */
  color: #fff;
  font-weight: bold;
  letter-spacing: 10px;
  text-align: center;
  /* 鼠标样式 */
  cursor: pointer;
  /* 边框、背景 */
  border-radius: 10px;
  background: linear-gradient(to right, #fbc2eb, #a6c1ee, #fbc2eb);
  background-size: 200%;
}

.btn:hover {
  animation: btnAnimate 1s infinite;
}

@keyframes btnAnimate {
  50% {
    background-position: 200%;
  }
}

a {
  text-decoration: none;
  color: #fbc2eb;
}
  </style>
</head>

<body>
  <div class="container">
    <div class="login-form">
      <div class="text">登录</div>
      <div class="form-item">
        <input type="text" placeholder="用户名">
        <input type="password" placeholder="密码">
      </div>
      <div class="btn">登录</div>
      <div class="btn-back"></div>
      <div class="other">
        没有账号?<a href="#">去注册</a>
      </div>
    </div>
  </div>

</body>

</html>
posted @ 2022-10-25 23:08  是小刘同学呀  阅读(360)  评论(0)    收藏  举报