希望你为我提供一些web前端开发期末作业的源码,包括html、css、
时间: 2023-11-25 20:05:19 浏览: 98
html+css+javascript网页设计源码 Web前端作业
5星 · 资源好评率100%
好的,下面是一些web前端开发期末作业的源码供您参考:
1. 简单的登录页面
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<style>
.container {
width: 300px;
margin: 0 auto;
text-align: center;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>登录</h2>
<form action="">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" placeholder="请输入用户名">
<label for="password">密码:</label>
<input type="password" id="password" name="password" placeholder="请输入密码">
<input type="submit" value="登录">
</form>
</div>
</body>
</html>
```
2. 一个简单的计算器
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>计算器</title>
<style>
.container {
width: 300px;
margin: 0 auto;
text-align: center;
}
input[type="text"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type="button"] {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="button"]:hover {
background-color: #45a049;
}
</style>
<script>
function calculate() {
var num1 = parseInt(document.getElementById("num1").value);
var num2 = parseInt(document.getElementById("num2").value);
var operator = document.getElementById("operator").value;
var result;
switch (operator) {
case "+":
result = num1 + num2;
break;
case "-":
result = num1 - num2;
break;
case "*":
result = num1 * num2;
break;
case "/":
result = num1 / num2;
break;
default:
result = "请输入正确的运算符";
break;
}
document.getElementById("result").value = result;
}
</script>
</head>
<body>
<div class="container">
<h2>计算器</h2>
<form>
<label for="num1">第一个数字:</label>
<input type="text" id="num1" name="num1" placeholder="请输入第一个数字">
<label for="operator">运算符:</label>
<input type="text" id="operator" name="operator" placeholder="请输入运算符">
<label for="num2">第二个数字:</label>
<input type="text" id="num2" name="num2" placeholder="请输入第二个数字">
<input type="button" value="计算" onclick="calculate()">
<label for="result">结果:</label>
<input type="text" id="result" name="result" readonly>
</form>
</div>
</body>
</html>
```
希望这些源码可以帮到您,如果您有其他需求,可以继续问我。
阅读全文