html实现好看的注册页面,html+css做一个好看的可翻转登录注册界面代码实例
时间: 2024-03-14 15:44:58 浏览: 117
好的,以下是一个简单的注册页面的 HTML 代码和 CSS 样式代码:
HTML 代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>注册页面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<form>
<h2>注册</h2>
<label for="username">用户名</label>
<input type="text" id="username" name="username">
<label for="email">邮箱</label>
<input type="text" id="email" name="email">
<label for="password">密码</label>
<input type="password" id="password" name="password">
<input type="submit" value="注册">
</form>
</div>
</body>
</html>
```
CSS 样式代码:
```css
body {
background-color: #f2f2f2;
}
.container {
width: 400px;
margin: 50px auto;
background-color: #fff;
padding: 30px;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
form {
display: flex;
flex-direction: column;
}
h2 {
font-size: 28px;
margin-bottom: 20px;
text-align: center;
}
label {
font-size: 18px;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
padding: 10px;
border-radius: 5px;
border: none;
margin-bottom: 20px;
}
input[type="submit"] {
background-color: #1abc9c;
color: #fff;
padding: 10px;
border-radius: 5px;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #16a085;
}
```
关于可翻转登录注册界面,可以使用 CSS3 的 transform 属性来实现,以下是示例代码:
HTML 代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录注册界面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="flipper">
<div class="front">
<h2>登录</h2>
<form>
<label for="username">用户名</label>
<input type="text" id="username" name="username">
<label for="password">密码</label>
<input type="password" id="password" name="password">
<input type="submit" value="登录">
<p>还没有账号?<a href="#" class="flipper-link">点击注册</a></p>
</form>
</div>
<div class="back">
<h2>注册</h2>
<form>
<label for="username">用户名</label>
<input type="text" id="username" name="username">
<label for="email">邮箱</label>
<input type="text" id="email" name="email">
<label for="password">密码</label>
<input type="password" id="password" name="password">
<input type="submit" value="注册">
<p>已有账号?<a href="#" class="flipper-link">点击登录</a></p>
</form>
</div>
</div>
</div>
<script src="app.js"></script>
</body>
</html>
```
CSS 样式代码:
```css
body {
background-color: #f2f2f2;
}
.container {
width: 400px;
margin: 50px auto;
}
.flipper {
position: relative;
perspective: 1000px;
}
.front,
.back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
backface-visibility: hidden;
transition: transform 0.6s ease;
}
.front {
z-index: 2;
}
.back {
transform: rotateY(180deg);
z-index: 1;
}
.flipper.flipped .front {
transform: rotateY(180deg);
z-index: 1;
}
.flipper.flipped .back {
transform: rotateY(0deg);
z-index: 2;
}
h2 {
font-size: 28px;
margin-bottom: 20px;
text-align: center;
}
form {
display: flex;
flex-direction: column;
}
label {
font-size: 18px;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
padding: 10px;
border-radius: 5px;
border: none;
margin-bottom: 20px;
}
input[type="submit"] {
background-color: #1abc9c;
color: #fff;
padding: 10px;
border-radius: 5px;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #16a085;
}
p {
text-align: center;
margin-top: 20px;
}
.flipper-link {
color: #1abc9c;
text-decoration: none;
font-weight: bold;
}
.flipper-link:hover {
text-decoration: underline;
}
@media only screen and (max-width: 480px) {
.container {
width: 100%;
margin: 20px auto;
}
}
```
JavaScript 代码:
```javascript
const flipper = document.querySelector('.flipper');
const flipperLinks = document.querySelectorAll('.flipper-link');
flipperLinks.forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
flipper.classList.toggle('flipped');
});
});
```
阅读全文