繁体   English   中英

无法在CSS中更改输入元素的宽度

[英]Cannot change width of input element in CSS

我正在尝试更改<td>元素内的<td> <input>的width属性。

我只是简单地尝试了这个,并尝试了更多类似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>
}

在你看来

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM