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

标签 html css

我正在尝试更改 <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/

相关文章:

css - Angular 6 : ngx-translate not working with data-title attribute for tooltips

html - 同时使用顶部、左侧、右侧和底部 css 来调整元素大小是否有效?

html - 如何在同一行制作3张图片,然后在下面制作3段

css - 突然错位的导航栏

javascript - html 在新目标和焦点上打开一个 url

javascript - 如何删除页面上的所有空白或空格 div?

html - 使 div 可缩放并保留其图像大小

javascript - 更改链接的 CSS 文件以删除特定 HTML 标记的样式

javascript - 在脚本jquery中调整图像大小

css - 头像 - 作者框 - 未对齐的 CSS