简体   繁体   English

CSS DIV默认宽度在IE中看起来不错。 不是Firefox

[英]CSS DIV Default width looks good in IE. Not Firefox

I've set up an example of what I'm running into here: http://studiozion.com/cssproblem/fix_it.htm . 我已经在这里建立了一个示例: http : //studiozion.com/cssproblem/fix_it.htm

Relevant code blocks... 相关代码块...

 <style type="text/css"> body { background: transparent url(Grade300_Color1.png) repeat-x } .RowMaker { overflow: auto; } .ColumnMaker { float: left; } .ColumnMaker2 { float: right; } .PadTop { padding-top: 10px; } .PadBot { padding-bottom: 10px; } .PadLeft { padding-left: 15px; } .PadRight { padding-right: 15px; } .ControlCurve1 { height: 6px; background: transparent url(ControlCurve1.png) no-repeat right -6px } .ControlCurveRight1 { height: 6px; width: 6px; background: transparent url(ControlCurve1.png) no-repeat top left } .ControlCurveLeft1 { height: 6px; width: 6px; background: transparent url(ControlCurve1.png) no-repeat bottom left } </style> 
 <div class="RowMaker"> <div class="ColumnMaker ControlCurveLeft1"><span></span></div> <div class="ColumnMaker ControlCurve1"> <div class="RowMaker"> <div class="ColumnMaker2 ControlCurveRight1"><span></span></div> </div> </div> </div> 

So the issue is that the div with class "ColumnMaker ControlCurve1" will expand to fill the width of parent container with class "RowMaker" in IE creating a nice little beveled cap for a div. 因此,问题是IE中的类为“ ColumnMaker ControlCurve1”的div将扩展为填充类为“ RowMaker”的父容器的宽度,从而为div创建一个漂亮的小斜角帽。 But in Firefox the "ColumnMaker ControlCurve1" div truncates causing the right side of the beveled cap to be left aligned. 但是在Firefox中,“ ColumnMaker ControlCurve1” div会被截断,导致斜角帽的右侧向左对齐。

So who is right? 那么谁是对的? And more importantly how do I go about fixing this while retaining the flexibilty of a visual element that expands to it's parent container? 更重要的是,如何在保留扩展到其父容器的可视元素的灵活性的同时解决此问题? I really don't want to set a hard width on "ColumnMaker Control1". 我真的不想在“ ColumnMaker Control1”上设置硬宽度。

firefox is always the right one (j/k) Firefox永远是正确的选择(j / k)

this problem has been solved many times before. 这个问题以前已经解决了很多次。 may i suggest a quick search to find things like 我可以建议您快速搜索一下,例如

http://redmelon.net/tstme/4corners/ http://redmelon.net/tstme/4corners/

http://kalsey.com/blog/2003/07/rounded_corners_in_css/ http://kalsey.com/blog/2003/07/rounded_corners_in_css/

there is also a jquery solution 还有一个jQuery的解决方案

http://www.malsup.com/jquery/corner/ http://www.malsup.com/jquery/corner/

you need to clear your floats. 您需要清除浮标。 in your stylesheet, include the following code for the CONTAINER that has floats in it: 在样式表中,为容器中包含浮点的代码添加以下代码:

#yourContainer:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}

you can also (and should also) clear your floats for IE by putting min-height: 10px; 您还可以(并且也应该)通过放置min-height: 10px;清除IE的浮动信息min-height: 10px; in your #yourContainer style definition. 在您的#yourContainer样式定义中。

It's also possible that because you have no content and have not set a width, the div will not stretch to anything. 也有可能因为您没有内容且没有设置宽度,所以div不会延伸到任何东西。

Just some thoughts looking at it without really testing. 只是一些想法,而没有真正测试。

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

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