我正在尝试更改 <input>
的宽度属性
<td>
内部
元素。
我已经简单地尝试过这个和更多的变体,比如 max-width 但没有任何改变。输入框的宽度还是一样的。它在经典的 html、css 文件中工作得很好,但由于某种原因在 asp.net 中出现了错误。感谢任何提示。
<table>
<tr>
<td><input class="numericInput"/></td>
</tr>
</table>
td {
max-height: 30px;
max-width: 30px;
border: 1px solid;
text-align: center;
}
input {
width: 20px;
}
最佳答案
你忘了把它放在样式标签里了吗?
<style>
td {
max-height: 30px;
max-width: 30px;
border: 1px solid;
text-align: center;
}
input {
width: 20px;
}
</style>
如果您使用@RenderBody()
,您可能还需要考虑以下选项,声明以下代码
@RenderSection("Styles", required: false)
在你的基本布局中添加下面的代码
@section styles{
<style>
/* your style here */
</style>
}
在你看来
关于html - 无法更改 CSS 中输入元素的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56892260/