简体   繁体   English

在chrome / IE中,浮动div旁边的字段集在右侧溢出,在FF中下一行

[英]Fieldset next to floated div overflows to the right in chrome/IE, breaks to the next line in FF

I am using Bootstrap 3. I have a containing element containing a floated div and a fieldset. 我正在使用Bootstrap3。我有一个包含元素,其中包含一个浮动div和一个字段集。 The floated div is 100% width so the fieldset should sit below it. 浮动div的宽度为100%,因此字段集应位于其下方。 This works in FF (which I was using to develop) but in chrome/IE, the fieldset overflows out of container and sits to the right of float . 这在FF(我用来开发)中起作用,但是在chrome / IE中,字段集溢出容器,并位于float的右侧。

在此处输入图片说明

 .container{ width:300px; position:relative; border:1px solid red; } .float{ float:left; width:100%; } 
 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="container"> <div style="float:left;width:100%;"> <a >Select All</a> / <a >Select None</a> </div> <fieldset>fieldset</fieldset> </div> 

I can fix it by adding clear:left; 我可以通过添加clear:left;来解决它clear:left; to the fieldset. 到字段集。

Which browser is correct? 哪个浏览器正确? It seems like FF is in the wrong. 似乎FF错误。 What rule is FF breaking or excepting to cause this to render differently? FF中断或例外导致此渲染不同的规则是什么? Is this a bug? 这是错误吗?

Noting that when not using bootstrap, it renders as expected in all browsers I tested. 请注意,当不使用引导程序时,它将在我测试的所有浏览器中按预期方式呈现。 Within bootstrap, if I use a div instead of a fieldset, it also renders the same across browsers. 在引导程序中,如果我使用div而不是字段集,它也会在浏览器中呈现相同的效果。

Looks like it's the fieldset default styling being over-ridden by the Bootstrap CSS. 看起来这是Bootstrap CSS覆盖的fieldset默认样式。 It's applying a min-width: 0 to fieldset which is causing the element to have no width. 它将min-width: 0应用于fieldset ,这导致元素没有宽度。 Not sure why this was added to Bootstrap but it's probably something to do with it's expected content being actual form fields as opposed to just text as per your example. 不确定为什么将其添加到Bootstrap中,但是可能与预期的内容是实际的表单字段有关,而不是根据示例显示的纯文本。 Try adding some valid form HTML as per the MDN link to see if that improves your situation. 尝试根据MDN链接添加一些有效的表单HTML,以查看是否可以改善您的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM