为什么浮动元素中浮动的控件在IE7中向右滑动太远,而在Firefox中没有?

时间:2022-04-23 08:44:53

Hopefully a picture is worth a thousand lines of code because I don't want to have to strip down all of the ASP.Net code, HTML, JavaScript, and CSS to provide an example (but I'll supply what I can upon request if someone doesn't say "Oh, I've seen that before! Try this...") [Actually, I did post some code and CSS - see bottom of question].

希望一张图片值得上千行代码,因为我不想删除所有的ASP.Net代码,HTML,JavaScript和CSS来提供一个例子(但我会根据要求提供我可以提供的代码)如果有人不说“哦,我以前见过这个!试试这个...”)[实际上,我确实发布了一些代码和CSS - 见问题的底部]。

Here is a portion of a form page being displayed in Firefox: 为什么浮动元素中浮动的控件在IE7中向右滑动太远,而在Firefox中没有?

以下是Firefox中显示的表单页面的一部分:

The blue boxes are temporary stylings of a <label> tag and the orange lines are temporary border styles of the <div> tags (so I can see where they extend and break). The <label>'s are styled to float: left as are the <div's on the right. In addition, the descendant controls of the <div> are also float:left purely so they will line up on the top of the <div> (since there are some taller controls like multiline textboxes down below).

蓝色框是

标签的临时边框样式(因此我可以看到它们延伸和断开的位置)。
为什么浮动元素中浮动的控件在IE7中向右滑动太远,而在Firefox中没有?

#1


2  

The input is inheriting the margins from the surrounding div and the ol. If you surround it with another tag like a span or a div, it should solve your problem.

输入继承了周围div和ol的边距。如果用另一个标签(如span或div)包围它,它应该可以解决您的问题。

Edit: You can find more information and workarounds at http://www.positioniseverything.net/explorer/inherited_margin.html

编辑:您可以在http://www.positioniseverything.net/explorer/inherited_margin.html找到更多信息和解决方法。