簡體   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