请用HTML和css和JavaScript写一份在线教育静态登录和注册页面的网页源代码,要求图文并茂
时间: 2024-03-12 12:46:45 浏览: 23
很抱歉,作为AI语言模型,我无法直接提供图文并茂的源代码。但是,我可以给您提供一些参考,帮助您了解如何使用HTML、CSS和JavaScript创建在线教育静态登录和注册页面。您可以参考以下示例代码:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>在线教育登录与注册页面</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div class="container">
<header>
<h1>在线教育平台</h1>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">课程</a></li>
<li><a href="#">关于</a></li>
<li><a href="#">联系我们</a></li>
</ul>
</nav>
</header>
<main>
<div class="form-container">
<form id="login-form">
<h2>登录</h2>
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
<button type="submit">登录</button>
</form>
<form id="register-form" style="display:none;">
<h2>注册</h2>
<label for="new-username">用户名:</label>
<input type="text" id="new-username" name="new-username" required>
<label for="new-password">密码:</label>
<input type="password" id="new-password" name="new-password" required>
<label for="confirm-password">确认密码:</label>
<input type="password" id="confirm-password" name="confirm-password" required>
<button type="submit">注册</button>
</form>
<p>还没有账号?<a href="#" onclick="showRegisterForm()">立即注册</a></p>
</div>
</main>
<footer>
<p>版权所有 © 2021 在线教育平台</p>
</footer>
</div>
</body>
</html>
```
CSS代码:
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
h1 {
font-size: 36px;
font-weight: bold;
color: #333;
}
nav ul {
display: flex;
list-style: none;
}
nav li {
margin-right: 20px;
}
nav a {
text-decoration: none;
color: #333;
font-size: 18px;
}
main {
display: flex;
justify-content: center;
align-items: center;
}
.form-container {
max-width: 400px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
}
h2 {
font-size: 24px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
label {
display: block;
font-size: 18px;
margin-bottom: 10px;
color: #333;
}
input[type="text"],
input[type="password"] {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
button[type="submit"] {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 18px;
cursor: pointer;
}
button[type="submit"]:hover {
background-color: #0056b3;
}
p {
margin-top: 20px;
font-size: 16px;
color: #333;
}
a {
color: #007bff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
```
JavaScript代码:
```javascript
function showRegisterForm() {
document.getElementById("login-form").style.display = "none";
document.getElementById("register-form").style.display = "block";
}
```
这个示例代码包括一个简单的登录和注册表单,并使用CSS样式布局和美化页面,还包括JavaScript代码,用于在单击“立即注册”链接时切换表单。您可以根据需要修改和扩展这个示例代码,以适应您的具体需求。