MVC 应用程序中的前端字段对齐

发布于 2024-10-13 10:08:21 字数 1362 浏览 4 评论 0原文

这样我们就有了一个 ASP.NET MVC 2 应用程序。问题是,在我们的前端,很多领域并不喜欢相互配合。我想说,大约 90-95% 的字段显示给用户,我们正在使用 HTML Helpers。我们还主要使用 MVC 2 中发布的新的“for”帮助器,例如 Html.DropDownListFor

看这张图: alt text

它们都使用上面提到的相同的 HTML Helper。这是该特定图片的代码:

    <td class="leftRightBorder">
        <%= Html.DropDownListFor(m => m.ResetDayComponent.ResetBusinessDayConvention, DropDownData.BusinessDayConventionList(), "", new { propertyName = "ResetDayComponent.ResetBusinessDayConvention", onchange = "UpdateField(this);" })%>
    </td>
</tr>
<tr>
    <td>Frequency</td>
    <td class="leftRightBorder">
        <%= Html.DropDownListFor(m => m.FixedComponent.PaymentFrequency, DropDownData.FrequencyDropList(), "", new { propertyName = "FixedComponent.PaymentFrequency",  onchange = "UpdateField(this);" })%>
    </td>
    <td />
    <td>Frequency</td>
    <td class="leftRightBorder">
        <%= Html.DropDownListFor(m => m.FloatingComponent.PaymentFrequency, DropDownData.FrequencyDropList(), "", new { propertyName = "FloatingComponent.PaymentFrequency", onchange = "UpdateField(this);" })%>
    </td>

第二个频率是您看到的频率,另一个频率位于这两个下拉列表左侧的表格中。

如何为整个应用程序中的下拉菜单、文本字段等设置通用长度,以便一切看起来一致而不混乱?

So we have an ASP.NET MVC 2 application. The problem is, on our front end, a lot of fields don't like up with each other. I'd say with about 90-95% of the fields displayed to the user we are using HTML Helpers. We also mainly use the new ones released in MVC 2, the "for" helpers, for example, Html.DropDownListFor

Look at this picture:
alt text

These are both using the same HTML Helper, mentioned above. Here is the code for that specific picture:

    <td class="leftRightBorder">
        <%= Html.DropDownListFor(m => m.ResetDayComponent.ResetBusinessDayConvention, DropDownData.BusinessDayConventionList(), "", new { propertyName = "ResetDayComponent.ResetBusinessDayConvention", onchange = "UpdateField(this);" })%>
    </td>
</tr>
<tr>
    <td>Frequency</td>
    <td class="leftRightBorder">
        <%= Html.DropDownListFor(m => m.FixedComponent.PaymentFrequency, DropDownData.FrequencyDropList(), "", new { propertyName = "FixedComponent.PaymentFrequency",  onchange = "UpdateField(this);" })%>
    </td>
    <td />
    <td>Frequency</td>
    <td class="leftRightBorder">
        <%= Html.DropDownListFor(m => m.FloatingComponent.PaymentFrequency, DropDownData.FrequencyDropList(), "", new { propertyName = "FloatingComponent.PaymentFrequency", onchange = "UpdateField(this);" })%>
    </td>

The second frequency is the one you see, the other is in a table to the left of these two dropdowns.

How can I set a common length for dropdowns, text fields, etc. throughout the app so everything looks consistent and not messy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巨坚强 2024-10-20 10:08:21

使用 级联样式表 定义 HTML 元素的全局样式:

select, textarea, input[type=text] { width: 300px; }

或仅在 < 内设置样式代码>.leftRightBorder

.leftRightBorder select, 
.leftRightBorder textarea, 
.leftRightBorder input[type=text] 
{
    width: 300px; 
}

use a cascading style sheet to define global styles for HTML elements:

select, textarea, input[type=text] { width: 300px; }

or to style only within .leftRightBorder

.leftRightBorder select, 
.leftRightBorder textarea, 
.leftRightBorder input[type=text] 
{
    width: 300px; 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文