如果你想将用户名和密码默认设置为”admin”,可以在HTML代码中给对应的input元素添加value属性。以下是修改后的示例代码:
<!DOCTYPE html>
<html>
<head>
<title>登录</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
width: 300px;
padding: 20px;
margin: 0 auto;
background-color: white;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
label {
display: block;
margin-top: 15px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
border-radius: 3px;
border: solid 1px #ccc;
}
button {
display:block; /* 将按钮设置为块级元素 */
width:auto; /* 自动调整宽度 */
margin-top:20px; /* 设置上边距 */
padding:.5em; /* 调整内边距 */
background-color:#4CAF50;
color:white;
border:none;
cursor:pointer;
}
button:hover {opacity:.7;}
</style>
</head>
<body>
<div class="container">
<h1>登录</h1>
<form action="" method="post">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" value="admin">
<label for="password">密码:</label>
<input type="password" id="password" name="password" value="admin">
<button type="submit">登录</button>
</form>
</div>
<script>
// JavaScript代码可以在这里添加,用于处理表单提交等其他交互逻辑
</script>
</body>
</html>
现在用户名和密码的默认值都被设置为”admin”。请记住,在实际应用中,为了安全性考虑,强烈建议不要使用默认的用户名和密码。以上示例仅供演示目的。
内容由零声教学AI助手提供,问题来源于学员提问