小胖墩er 小胖墩er
首页
  • 前端文章

    • JavaScript
    • Vue
    • ES6
    • Git
  • Vue
  • React
  • HTML
  • CSS
  • 工具类
  • GitHub技巧
  • 博客搭建
  • 友情链接
💖关于
💻收藏
  • 分类
  • 标签
  • 归档
📭主页 (opens new window)
GitHub (opens new window)

小胖墩er

Better later than never.
首页
  • 前端文章

    • JavaScript
    • Vue
    • ES6
    • Git
  • Vue
  • React
  • HTML
  • CSS
  • 工具类
  • GitHub技巧
  • 博客搭建
  • 友情链接
💖关于
💻收藏
  • 分类
  • 标签
  • 归档
📭主页 (opens new window)
GitHub (opens new window)
  • HTML

    • 滑动登录界面
    • svg基本绘制
  • 页面
  • HTML
小胖墩er
2021-11-23

滑动登录界面

实现的是登录与注册之间相互切换,背景也会跟着改变的效果

login

body {
  background-color: #ededed;
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.flexCenter {
  display: flex;
  align-items: center;
  justify-content: center;
}

.main {
  position: relative;
  width: 900px;
  height: 550px;
  margin: auto;
  overflow: hidden;
  border: 1px solid #ccc;
}

.switchWrapper {
  position: absolute;
  z-index: 99;
  left: 0;
  overflow: hidden;
  width: 32%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.4);
  transition: transform 1s ease-in-out;
}

/* 背景跟随滚动 */
.switchWrapper::after {
  content: '';
  display: block;
  background-image: url('./pc.png');
  background-size: 900px 550px;
  background-position: top left;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transition: all 1s ease-in-out;
}

.active .switchWrapper::after {
  background-position: top right;
}

/* 背景跟随滚动  end*/

.btn {
  position: absolute;
  width: 90px;
  height: 36px;
  color: #fffffe;
  background-color: #ff8906;
  font-size: 15px;
  border-radius: 30px;
  cursor: pointer;
  flex-wrap: wrap;
  overflow: hidden;
}

.active .switchWrapper {
  transform: translateX(calc(900px - 100%));
}

/* 垂直文字 */
.text {
  width: 100%;
  height: 100%;
  transition: all 1s ease-in-out;
  user-select: none;
}

.active .text:first-child {
  margin-top: -100%;
}

/* 内容区 */
.outerBox {
  position: absolute;
  z-index: 9;
  left: 32%;
  overflow: hidden;
  width: 68%;
  height: 100%;
  transition: all 1s ease-in-out;
}

.container {
  width: 100%;
  height: 100%;
  background-color: #fffffe;
}

.active .outerBox {
  transform: translateX(calc(-900px + 100%));
}
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
<div class="main">
  <!--功能区-->
  <div class="switchWrapper flexCenter">
    <div class="btn flexCenter">
      <div class="text flexCenter">去登录</div>
      <div class="text flexCenter">去注册</div>
    </div>
  </div>

  <!-- 表单区域 -->
  <div class="outerBox">
    <div class="container flexCenter">
      <div class="signInBox">
        <div class="tips">注册内容区</div>
        <div>
          <input type="text">
        </div>
        <div>
          <input type="text">
        </div>
        <button class="regLog">注册</button>
      </div>
    </div>
  </div>

</div>
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
const main = document.querySelector('.main');
const btn = document.querySelector('.btn');
const signInBox = document.querySelector('.signInBox');
const tips = document.querySelector('.tips');
const regLogBtn = document.querySelector('.regLog');
btn.onclick = () => {
  if (main.className.indexOf('active') != -1) {
    main.className = 'main';
    setTimeout(() => {
      tips.innerText = '注册内容区';
      regLogBtn.innerText = '注册';
    }, 500);
  } else {
    main.className = 'main active';
    setTimeout(() => {
      tips.innerText = '登录内容区';
      regLogBtn.innerText = '登录';
    }, 500);
  }
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
在线编辑 (opens new window)
#页面
上次更新: 2021/11/23, 15:19:29
svg基本绘制

svg基本绘制→

最近更新
01
毛玻璃效果
11-23
02
svg基本绘制
11-23
03
CSS选取第n个标签元素
11-18
更多文章>
🖥️

© 2021 小胖墩er 💌 粤ICP备2021158933号 🛀 Theme by 💝 Vdoing

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×