当前位置:   article > 正文

html登录页面_登录页html

登录页html

效果图

在这里插入图片描述

html代码

index.html

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>log_in</title>
    <script src="script.js"></script>
    <link rel="stylesheet" href="css/style.css" />
</head>

<body>
    <div class="container">
        <h1>Please login</h1>
        <form>
            <div class="form-control">
                <input type="text" required>
                <label>
                    Email
                </label>
            </div>
            <div class="form-control">
                <input type="password" required>
                <label>password</label>
            </div>
            <button class="btn">Login</button>
            <p class="text">Don't have an account?<a href="">Register</a></p>
        </form>
    </div>
</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

css代码

style.css

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    height: 100vh;
    background: rgb(255, 94, 249);
    background: linear-gradient(144deg, rgba(255, 94, 249, 1) 19%, rgba(104, 185, 251, 1) 86%);
    color: white;
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 表单属性 */
.container {
    background-color: rgb(0, 0, 0, 0.4);
    padding: 20px 40px;
    border-radius: 5px;
}

/* 表单中标题属性 */
.container h1 {
    text-align: center;
    margin-bottom: 30px;
    font-family: '楷体', '微软雅黑';

}

/* 鼠标经过时字体颜色改变 */
.container h1:hover {
    background-image: linear-gradient(90deg, #673ab7, #e91e63);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(90deg,
            rgb(255, 167, 69),
            rgb(254, 134, 159),
            rgb(239, 122, 200),
            rgb(160, 131, 237),
            rgb(67, 174, 255),
            rgb(160, 131, 237),
            rgb(239, 122, 200),
            rgb(254, 134, 159),
            rgb(255, 167, 69));
    background-size: 200%;
    animation: streamer 3s linear infinite;
}

/* 字体颜色变化的动画 */
@keyframes streamer {
    0% {
        background-position: 200%;
    }

    100% {
        background-position: 0%;
    }
}

/* 按钮的属性 */
.btn {
    cursor: pointer;
    width: 100%;
    background-color: lightblue;
    padding: 15px;
    border: 0;
    font-size: 16px;
    font-family: inherit;
}

/* 点击按钮时的属性 */
.btn:focus {
    outline: 0;
}

/* 点击按钮时的效果,缩小0.98 */
.btn:active {
    transform: scale(0.98);
}

/* 下面注册旁的连接 */
.container a {
    text-decoration: none;
    color: lightblue;
}

.text {
    margin-top: 30px;
}

/* 输入框所在容器的类 */
.form-control {
    width: 300px;
    margin: 20px 0 40px;
    position: relative;
}

.form-control input {
    width: 100%;
    background-color: transparent;
    border: 0;
    border-bottom: 2px solid white;
    display: block;
    padding: 15px 0;
    font-size: 18px;
    color: white;
}

/* 获取焦点时下边框变为蓝色 */
.form-control input:focus {
    outline: 0;
    border-bottom-color: lightblue;
}

/*当输入框中有文字时,下边框还是蓝色  valid:检测input有没有填*/
.form-control input:valid {
    border-bottom-color: lightblue;
}

/* Email与password的属性 */
.form-control label {
    position: absolute;
    left: 0;
    top: 15px;
}

/* Email与password的动画效果 */
.form-control label span {
    display: inline-block;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* +选择器:选择除了自己之外的其它兄弟元素 */
.form-control input:focus+label span,
.form-control input:valid+label span {
    transform: translateY(-30px);
    color: lightblue;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143

javaScript代码

script.js

window.onload = function () {
    const labels = document.querySelectorAll(".form-control label")
    labels.forEach(label => {
        label.innerHTML = label.innerText.split('').map((letter, index) => `<span style="transition-delay:${index * 35}ms">${letter}</span>`).join('');
    });
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Vue3版本

Login/index.vue

<template>
  <div class="container">
    <h1>Please login</h1>
    <form @submit.prevent="login">
      <div class="form-control">
        <input type="text" v-model="email" required>
        <label>
          <span v-for="(letter, index) in splitLetters('Email')" :key="index" :style="{transitionDelay: letter.delay}">
            {{ letter.char }}
          </span>
        </label>
      </div>
      <div class="form-control">
        <input type="password" v-model="password" required>
        <label>
          <span v-for="(letter, index) in splitLetters('Password')" :key="index"
                :style="{transitionDelay: letter.delay}">
            {{ letter.char }}
          </span>
        </label>
      </div>
      <button class="btn">Login</button>
      <p class="text">Don't have an account?<a href="#">Register</a></p>
    </form>
  </div>
</template>

<script setup>
import {ref} from 'vue';

const email = ref('');
const password = ref('');

const splitLetters = (word) => {
  return [...word].map((char, index) => ({
    char,
    delay: `${index * 35}ms`,
  }));
};

const login = () => {
  console.log(email.value, password.value);
  // 这里处理登录逻辑
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  min-height: 100vh; /* 视口高度 */
  display: flex;
  flex-direction: column;
  justify-content: center; /* 垂直居中 */
  align-items: center; /* 水平居中 */
  background: linear-gradient(144deg, rgba(255, 94, 249, 1) 19%, rgba(104, 185, 251, 1) 86%); /* 背景渐变 */
  color: white; /* 文字颜色 */
}

/* 表单中标题属性 */
.container h1 {
  text-align: center;
  margin-bottom: 30px;
  font-family: '楷体', '微软雅黑';

}

/* 鼠标经过时字体颜色改变 */
.container h1:hover {
  background-image: linear-gradient(90deg, #673ab7, #e91e63);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-image: linear-gradient(90deg,
  rgb(255, 167, 69),
  rgb(254, 134, 159),
  rgb(239, 122, 200),
  rgb(160, 131, 237),
  rgb(67, 174, 255),
  rgb(160, 131, 237),
  rgb(239, 122, 200),
  rgb(254, 134, 159),
  rgb(255, 167, 69));
  background-size: 200%;
  animation: streamer 3s linear infinite;
}

/* 字体颜色变化的动画 */
@keyframes streamer {
  0% {
    background-position: 200%;
  }

  100% {
    background-position: 0%;
  }
}

/* 按钮的属性 */
.btn {
  cursor: pointer;
  width: 100%;
  background-color: lightblue;
  padding: 15px;
  border: 0;
  font-size: 16px;
  font-family: inherit;
}

/* 点击按钮时的属性 */
.btn:focus {
  outline: 0;
}

/* 点击按钮时的效果,缩小0.98 */
.btn:active {
  transform: scale(0.98);
}

/* 下面注册旁的连接 */
.container a {
  text-decoration: none;
  color: lightblue;
}

.text {
  margin-top: 30px;
}

/* 输入框所在容器的类 */
.form-control {
  width: 300px;
  margin: 20px 0 40px;
  position: relative;
}

.form-control input {
  width: 100%;
  background-color: transparent;
  border: 0;
  border-bottom: 2px solid white;
  display: block;
  padding: 15px 0;
  font-size: 18px;
  color: white;
}

/* 获取焦点时下边框变为蓝色 */
.form-control input:focus {
  outline: 0;
  border-bottom-color: lightblue;
}

/*当输入框中有文字时,下边框还是蓝色  valid:检测input有没有填*/
.form-control input:valid {
  border-bottom-color: lightblue;
}

/* Email与password的属性 */
.form-control label {
  position: absolute;
  left: 0;
  top: 15px;
}

/* Email与password的动画效果 */
.form-control label span {
  display: inline-block;
  font-size: 18px;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* +选择器:选择除了自己之外的其它兄弟元素 */
.form-control input:focus + label span,
.form-control input:valid + label span {
  transform: translateY(-30px);
  color: lightblue;
}

</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185

App.vue

<template>
  <div id="app">
    <Login />
  </div>
</template>

<script>
import Login from '@/components/Login/index.vue';

export default {
  name: 'App',
  components: {
    Login:Login
  },
};
</script>

<style>
/* Global styles */
html, body, #app {
  height: 100%;
  margin: 0;
}
</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

在这里插入图片描述

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/664504
推荐阅读
相关标签
  

闽ICP备14008679号