请添加图片描述

文件夹结构:
在这里插入图片描述
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>Document</title>
    <link rel="stylesheet" href="./css/normalize.css" />
    <link rel="stylesheet" href="./css/index.css" />
</head>
<body>
    <section>
        <div class="card">
            <div class="left">
                <p class="left-1">中国科学院</p>
                <p class="left-2">深圳理工大学</p>
                <img src="siat.png" alt="">
                <p class="left-3">没有账号?请注册</p>
                <button class="left-btn">去注册</button>
            </div>
            <div class="right">
                <p class="right-1">中国科学院</p>
                <p class="right-2">深圳先进技术研究院</p>
                <img src="siat1.png" alt="">
                <p class="right-3">已账号?请登录</p>
                <button class="right-btn">去登录</button>
            </div>
        </div>
        <div class="box">
            <p>LOGIN</p>
            <input type="text" value="用户名" class="box-1">
            <input type="text" value="密码" class="box-2">
            <button class="box-btn">登录</button>
        </div>
    </section>
    <script src="./js/index.js"></script>

</body>
</html>

index.css:

html {
  font-size: 50px;
}
@media screen and (min-width: 320px) {
  html {
    font-size: 21.33333333px;
  }
}
@media screen and (min-width: 360px) {
  html {
    font-size: 24px;
  }
}
@media screen and (min-width: 375px) {
  html {
    font-size: 25px;
  }
}
@media screen and (min-width: 384px) {
  html {
    font-size: 25.6px;
  }
}
@media screen and (min-width: 400px) {
  html {
    font-size: 26.66666667px;
  }
}
@media screen and (min-width: 414px) {
  html {
    font-size: 27.6px;
  }
}
@media screen and (min-width: 424px) {
  html {
    font-size: 28.26666667px;
  }
}
@media screen and (min-width: 480px) {
  html {
    font-size: 32px;
  }
}
@media screen and (min-width: 540px) {
  html {
    font-size: 36px;
  }
}
@media screen and (min-width: 720px) {
  html {
    font-size: 48px;
  }
}
@media screen and (min-width: 750px) {
  html {
    font-size: 50px;
  }
}
body {
  min-width: 320px;
  width: 15rem;
  margin: 0 auto;
  line-height: 1.5;
  font-family: Arial,Helvetica;
  background: #ecfdea;
}
section {
  position: relative;
}
.card {
  display: flex;
  width: 12rem;
  height: 6rem;
  margin: 6rem auto;
  box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.4);
}
.card .left {
  flex: 1;
  position: relative;
  text-align: center;
  font-size: 0.44rem;
  width: 6rem;
  height: 6rem;
  background-color: #fd833d;
}
.card .left .left-1 {
  margin-top: 0.24rem;
  letter-spacing: 0.04rem;
  color: #fff;
}
.card .left .left-2 {
  font-size: 0.48rem;
  letter-spacing: 0.12rem;
  color: #fff;
}
.card .left img {
  position: absolute;
  top: -2.1rem;
  left: -2.8rem;
  width: 200%;
}
.card .left .left-3 {
  position: absolute;
  top: 4.4rem;
  font-size: 0.28rem;
  color: #fff;
  left: 50%;
  width: 4rem;
  transform: translateX(-50%);
}
.card .left .left-btn {
  position: absolute;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 2rem;
  height: 0.6rem;
  color: #fff;
  background-color: #7921a1;
  border: 1px solid #fff;
  font-size: 0.28rem;
  border-radius: 0.28rem;
}
.card .right {
  flex: 1;
  position: relative;
  text-align: center;
  font-size: 0.44rem;
  width: 6rem;
  height: 6rem;
  background-color: #bde5fc;
}
.card .right img {
  position: absolute;
  top: 0.5rem;
  left: -0.3rem;
  width: 110%;
}
.card .right .right-1 {
  margin-top: 0.24rem;
  letter-spacing: 0.04rem;
  color: #013356;
}
.card .right .right-2 {
  font-size: 0.48rem;
  letter-spacing: 0.02rem;
  color: #013356;
}
.card .right .right-3 {
  position: absolute;
  top: 4.45rem;
  font-size: 0.28rem;
  color: #013356;
  left: 50%;
  width: 4rem;
  transform: translateX(-50%);
}
.card .right .right-btn {
  position: absolute;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 2rem;
  height: 0.6rem;
  color: #013356;
  background-color: #fff;
  border: 1px solid #013356;
  font-size: 0.28rem;
  border-radius: 0.28rem;
}
.box {
  position: absolute;
  text-align: center;
  top: -0.75rem;
  left: 7.5rem;
  width: 5.5rem;
  height: 7.5rem;
  background-color: #fff;
  color: #7921a1;
  border: 2px solid #7921a1;
  box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
  z-index: 999;
}
.box p {
  font-size: 0.68rem;
  font-weight: 700;
  margin-top: 1.2rem;
}
.box input {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.28rem;
  text-decoration: solid;
  color: #7921a1;
  border-bottom: 1px solid #7921a1;
}
.box .box-1 {
  top: 2.7rem;
}
.box .box-2 {
  top: 3.7rem;
}
.box button {
  position: absolute;
  transition: all 0.5s;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 3.6rem;
  height: 0.7rem;
  font-size: 0.28rem;
  border: 1px solid #fff;
  color: #fff;
  border-radius: 0.2rem;
  font-weight: 500;
  background-color: #7921a1;
}

index.js:

var leftbtn = document.querySelector('.left-btn');
var rightbtn = document.querySelector('.right-btn');
var box = document.querySelector('.box');
var width = box.offsetWidth;
leftbtn.addEventListener('click',function() {
    var translatex = -width;
    box.style.transition = 'all .5s'
    box.style.transform = 'translateX(' + translatex + 'px)'
    box.children[0].innerHTML = 'REGISTER';
    box.style.border = '1px solid #013356';
    box.style.color = '#013356';
    box.children[1].style.borderBottom = '1px solid #013356';
    box.children[2].style.borderBottom = '1px solid #013356';
    box.children[3].style.backgroundColor = '#013356';
    box.children[1].style.color = '#013356';
    box.children[2].style.color = '#013356';
    box.children[3].innerHTML = '注册';
    var input = document.createElement('input');
    box.appendChild(input);
    box.children[4].value = '确认密码';
    box.children[4].style.color = '#013356';
    box.children[4].style.borderBottom = '1px solid #013356';
    box.children[4].style.top = '4.7rem';
    box.children[3].style.top = '5.7rem';
})
rightbtn.addEventListener('click',function() {
    box.style.transition = 'all .5s'
    box.style.transform = 'translateX(' + 0 + 'px)'
    box.children[0].innerHTML = 'LOGIN';
    box.style.border = '1px solid rgb(121, 33, 161)';
    box.style.color = 'rgb(121, 33, 161)';
    box.children[1].style.borderBottom = '1px solid rgb(121, 33, 161)';
    box.children[2].style.borderBottom = '1px solid rgb(121, 33, 161)';
    box.children[3].style.backgroundColor = 'rgb(121, 33, 161)';
    box.children[1].style.color = 'rgb(121, 33, 161)';
    box.children[2].style.color = 'rgb(121, 33, 161)';
    box.children[3].innerHTML = '登录';
    box.removeChild(box.children[4]);
    box.children[3].style.top = '5rem';
    box.children[3].style.color = '#fff';
})

normalize.css:
这个就是css的初始化文件


html {
  line-height             : 1.15;
  /* 1 */
  -webkit-text-size-adjust: 100%;
  /* 2 */
}

body {
  margin: 0;
}

main {
  display: block;
}

h1 {
  font-size: 2em;
  margin   : 0.67em 0;
}

hr {
  box-sizing: content-box;
  /* 1 */
  height    : 0;
  /* 1 */
  overflow  : visible;
  /* 2 */
}

pre {
  font-family: monospace, monospace;
  /* 1 */
  font-size  : 1em;
  /* 2 */
}
a {
  background-color: transparent;
}
abbr[title] {
  border-bottom  : none;
  /* 1 */
  text-decoration: underline;
  /* 2 */
  text-decoration: underline dotted;
  /* 2 */
}
b,
strong {
  font-weight: bolder;
}
code,
kbd,
samp {
  font-family: monospace, monospace;
  /* 1 */
  font-size  : 1em;
  /* 2 */
}
small {
  font-size: 80%;
}
sub,
sup {
  font-size     : 75%;
  line-height   : 0;
  position      : relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}
img {
  border-style: none;
}
button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  /* 1 */
  font-size  : 100%;
  /* 1 */
  line-height: 1.15;
  /* 1 */
  margin     : 0;
  /* 2 */
}
button,
input {
  /* 1 */
  overflow: visible;
}
button,
select {
  /* 1 */
  text-transform: none;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
  border-style: none;
  padding     : 0;
}
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
  outline: 1px dotted ButtonText;
}
fieldset {
  padding: 0.35em 0.75em 0.625em;
}
legend {
  box-sizing : border-box;
  /* 1 */
  color      : inherit;
  /* 2 */
  display    : table;
  /* 1 */
  max-width  : 100%;
  /* 1 */
  padding    : 0;
  /* 3 */
  white-space: normal;
  /* 1 */
}
progress {
  vertical-align: baseline;
}
textarea {
  overflow: auto;
}
[type="checkbox"],
[type="radio"] {
  box-sizing: border-box;
  /* 1 */
  padding   : 0;
  /* 2 */
}

[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
  height: auto;
}
[type="search"] {
  -webkit-appearance: textfield;
  /* 1 */
  outline-offset    : -2px;
  /* 2 */
}
[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}
::-webkit-file-upload-button {
  -webkit-appearance: button;
  /* 1 */
  font              : inherit;
  /* 2 */
}
details {
  display: block;
}
summary {
  display: list-item;
}
template {
  display: none;
}
[hidden] {
  display: none;
}

input {
  border    : none;
  outline   : none;
  background: none;
}

ul,
li {
  padding   : 0;
  list-style: none;
}

p {
  margin: 0;
}

img {
  display: block;
  width  : 100%;
}

* {
  box-sizing: border-box;
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐