1
我试图调整我的<fieldset>
元素的大小,但会自动缩小其内容。然后,我在我的CSS文件中添加了display:inline-block
(正如许多类似主题的答案中所建议的那样)。但是,这完全没有帮助,一切都保持不变。我该怎么办?我想要一个小巧友好的解决方案,因为我不擅长CSS,因为您可能已经注意到了。干杯!防止字段集调整内容的大小
fieldset {
display: inline-block;
border: 1px solid blue;
background-color: white;
width: 40%;
}
legend {
display: inline-block;
padding: 4px 8px;
border: 1px solid blue;
font-size: 15px;
color: white;
background-color: blue;
text-align: left;
}
label {
width: 100px;
margin-right: 30px;
display: inline-block;
text-align: left;
}
input[type=text] {
width: 25%;
padding: 10px 20px;
margin: 0px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
<fieldset>
<legend>XXX</legend>
<label for="username">Username:</label>
<input type="text" name="username">
</fieldset>