IE6 HTML 控件包装

发布于 2024-09-01 11:49:51 字数 225 浏览 4 评论 0原文

有什么方法可以防止 IE6 中控件之间的换行吗?例如,我有一个标签和一个选择框。选择框宽度是动态的(取决于内容)。我希望标签始终位于选择框的左侧。现在我遇到的问题是选择框落在标签下方。我尝试过使用 标签以及 CSS 自动换行规则,但因为这不是文本,所以换行规则不适用。我发现确保其工作的唯一方法是将它们放在两列表中,但我不喜欢这个解决方案。还有其他办法吗?

Is there any way to prevent wrapping across controls in IE6? For example, I have a label and a single select box. The select box width is dynamic (depending on the content). I want the label to always be to the left of the select box. Right now the problem I am having is the select box drops below the label. I have tried using the <nobr> tag as well as CSS word-wrap rules, but because this isn't text the wrapping rules do not apply. The only way I have found for sure to make it work is to place them in a two-column table, but I do not like this solution. Is there any other way?

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

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

发布评论

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

评论(1

长不大的小祸害 2024-09-08 11:49:51

如果标签和输入都有内联显示(“display: inline;”)并且输入换行,则父容器可能太窄。话虽如此,典型的水平标签表单布局并不依赖于这种内联显示,它们采用了一种利用块级浮动元素的更受控制的方法。例如,给定以下 HTML:

<div class="field">
    <label for="fieldId">field label</label> 
    <input id="fieldId" name="field" />
</div>

您可以使用以下 CSS 设置标签的位置:

.field {
    overflow: hidden; /* clear float */
}
.field label {
    display: block;
    float: left;
    margin: 0 5px 0 0;
}

有一个 具体细节有很多变化,但上面传达了基本概念。

If both the label and the input have an inline display ("display: inline;") and the input is breaking to a new line, then chances are the parent container is too narrow. With that said, typical horizontal-label form layouts don't rely on this inline display, they take a more controlled approach utilizing block-level, floated elements. For example, given the following HTML:

<div class="field">
    <label for="fieldId">field label</label> 
    <input id="fieldId" name="field" />
</div>

You could set the position of the label with the following CSS:

.field {
    overflow: hidden; /* clear float */
}
.field label {
    display: block;
    float: left;
    margin: 0 5px 0 0;
}

There's a ton of variations on the specifics, but the above conveys the basic concept.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文