【发布时间】:2021-09-09 20:03:39
【问题描述】:
我想创建一个简单的调查表,但遇到了宽度问题。 文本字段大约比我创建的调查表单框大 10 像素。我不明白我在css文件中将它设置为宽度:100%。问题出在哪里?
.survey-form {
width: 50%;
margin-left: 30%;
margin-right: 30%;
background: blue;
}
.form-control {
width: 100%;
}
<html>
<head>
<meta charset="utf-8">
<title>Bin</title>
</head>
<body>
<form class="survey-form">
<label for="name">Name</label>
<input class="name form-control" type="text" placeholder="Name" />
</form>
</body>
<html>
The width from the textfield is not the same as the blue box
【问题讨论】:
-
你的类“
name form-control”在你的 CSS 中不存在。我建议不要在类名和 id 等 html 说明符中使用空格。你在哪里包含你的样式表? -
OP在css中有class form-control,你可以为一个元素添加多个class