要更改表单输入背景颜色,您可以使用CSS来实现
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>表单输入背景颜色</title>
</head>
<body>
<form>
<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>
</body>
</html>
/* 修改表单输入框的背景颜色 */
input[type="text"], input[type="password"] {
background-color: #f0f0f0; /* 您喜欢的颜色 */
border: 1px solid #ccc;
padding: 5px;
font-size: 14px;
}
其中,input[type="text"], input[type="password"]
是用来选择所有文本输入框和密码输入框的选择器。您可以根据需要修改背景颜色以及其他样式。
现在,您可以在浏览器中打开 index.html 文件,您应该能看到表单输入框的背景颜色已经更改为您指定的颜色。
领取专属 10元无门槛券
手把手带您无忧上云