MVC 3 和 RTL - IE9 问题

发布于 2025-01-05 18:46:16 字数 811 浏览 1 评论 0原文

我一直在使用一个非常简单的 ASP.Net MVC3 项目来试验字符串和 RTL 的本地化。我有一个看起来像这样的视图:


@model LocalizationExample.Models.HomeModel

@using Microsoft.License.Ux.Partner.LanguageResources.Order;
@{
    ViewBag.Title = "Index";
}

<h2>@OrderResource.PageTitle</h2>
<div dir="rtl">
        @Html.LabelFor(x => x.Field1) @Html.TextBoxFor(x => x.Field1)<br />
        @Html.LabelFor(x => x.Field2) @Html.TextBoxFor(x => x.Field2)<br />
        @Html.LabelFor(x => x.Field3) @Html.TextBoxFor(x => x.Field3)<br />
</div>

In FireFox 10 & Chrome 17 中,这会产生三行文本框,标签位于右侧 - 全部在浏览器的右侧对齐。

在 IE9 中,前两个文本框的标签位于左侧,最后一个文本框的标签位于右侧 - 所有文本框都在浏览器的右侧对齐。

我尝试将“dir”移动到 body 标记以及 html 标记,但得到了相同的结果。我怎样才能让它在 IE9 中正确显示?

提前致谢!

I've been working with a very simple ASP.Net MVC3 project to experiment with localization of strings and RTL. I have a view that looks like this:


@model LocalizationExample.Models.HomeModel

@using Microsoft.License.Ux.Partner.LanguageResources.Order;
@{
    ViewBag.Title = "Index";
}

<h2>@OrderResource.PageTitle</h2>
<div dir="rtl">
        @Html.LabelFor(x => x.Field1) @Html.TextBoxFor(x => x.Field1)<br />
        @Html.LabelFor(x => x.Field2) @Html.TextBoxFor(x => x.Field2)<br />
        @Html.LabelFor(x => x.Field3) @Html.TextBoxFor(x => x.Field3)<br />
</div>

In FireFox 10 & Chrome 17, this results in three rows of TextBox's with the Labels on the right - all aligned on the right side of the browser.

In IE9, the first two textboxes have the labels to the left and the last textbox has the label to the right - all are aligned on the right side of the browser.

I've tried moving the "dir" up to the body tag and also to the html tag, but I get the same result. How can I get this to display correctly in IE9?

Thanks in advance!

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

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

发布评论

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

评论(1

花期渐远 2025-01-12 18:46:16

如果将它们嵌套在 div 内,它们似乎会正确对齐:

<div dir="rtl">
    <div>
        @Html.LabelFor(x => x.Field1) @Html.TextBoxFor(x => x.Field1)
    </div>
    <div>
        @Html.LabelFor(x => x.Field2) @Html.TextBoxFor(x => x.Field2)
    </div>
    <div>
        @Html.LabelFor(x => x.Field3) @Html.TextBoxFor(x => x.Field3)
    </div>
</div>

They seem to align properly if you nest them inside divs:

<div dir="rtl">
    <div>
        @Html.LabelFor(x => x.Field1) @Html.TextBoxFor(x => x.Field1)
    </div>
    <div>
        @Html.LabelFor(x => x.Field2) @Html.TextBoxFor(x => x.Field2)
    </div>
    <div>
        @Html.LabelFor(x => x.Field3) @Html.TextBoxFor(x => x.Field3)
    </div>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文