优化以上代码,使其更美观、视觉效果更佳,给出整合后的最终代码
时间: 2024-03-14 11:43:12 浏览: 58
以下是经过优化后的嵌入式设备登录页面的HTML、CSS和JS代码示例:
HTML代码:
```
<!DOCTYPE html>
<html>
<head>
<title>嵌入式设备登录</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="login-box">
<img src="background.jpg" class="background">
<h1>设备登录</h1>
<form>
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="登录">
</form>
</div>
</body>
</html>
```
CSS代码:
```
body {
background-color: #f2f2f2;
}
.login-box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background-color: #fff;
padding: 50px;
border-radius: 10px;
box-shadow: 0 0 20px 0 rgba(0,0,0,0.2);
}
.background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
filter: blur(5px);
}
h1 {
margin: 0 0 30px;
padding: 0;
font-size: 28px;
text-align: center;
color: #333;
text-shadow: 2px 2px 2px rgba(0,0,0,0.2);
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 10px;
font-size: 18px;
color: #333;
text-shadow: 2px 2px 2px rgba(0,0,0,0.2);
}
input[type="text"], input[type="password"] {
padding: 10px;
border: none;
border-radius: 5px;
background-color: #f2f2f2;
color: #333;
box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
}
input[type="submit"] {
margin-top: 20px;
padding: 10px;
border: none;
border-radius: 5px;
background-color: #f90;
background-image: linear-gradient(to bottom, #f90, #f60);
color: #fff;
font-size: 18px;
cursor: pointer;
box-shadow: 0 2px 2px rgba(0,0,0,0.2);
}
input[type="submit"]:hover {
background-image: linear-gradient(to bottom, #f60, #f90);
}
```
JS代码:
```
// 暂无JS代码
```
在这个优化后的示例中,我们添加了文本阴影、内部框阴影和渐变背景等效果,使页面看起来更加美观。我们还添加了鼠标悬停时的渐变效果,以提高交互性。请记住,这只是一个示例,您可以根据具体需求进行修改和优化。
阅读全文