Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css IE7:包含元素“float:right;”的Clearfix容器造成的额外空间和边际_Css_Html_Internet Explorer_Internet Explorer 7 - Fatal编程技术网

Css IE7:包含元素“float:right;”的Clearfix容器造成的额外空间和边际

Css IE7:包含元素“float:right;”的Clearfix容器造成的额外空间和边际,css,html,internet-explorer,internet-explorer-7,Css,Html,Internet Explorer,Internet Explorer 7,我在IE7中遇到了一个奇怪的错误,它似乎增加了两次保证金。一次在元素下方的正常位置,另一次在按钮和容器底部之间。注意,按钮本身有页边距底部,但我指的是在其下方添加的额外页边距 您可以在下面的gif中看到,当我在thing元素上切换边距底部时,它会在thing元素和按钮(正常)之间切换空格,也会在按钮和容器末端之间切换空格(错误) 我感觉这是缩放的一部分:1hasLayout clearfix用于.block。如果我添加一个显式的clear:bothdiv,它也有这个额外的空间,但是可以通过放置h

我在IE7中遇到了一个奇怪的错误,它似乎增加了两次保证金。一次在
元素下方的正常位置,另一次在按钮和容器底部之间。注意,按钮本身有
页边距底部
,但我指的是在其下方添加的额外页边距

您可以在下面的gif中看到,当我在
thing
元素上切换
边距底部时,它会在
thing
元素和按钮(正常)之间切换空格,也会在按钮和容器末端之间切换空格(错误)

我感觉这是缩放的一部分:1
hasLayout clearfix用于
.block
。如果我添加一个显式的
clear:both
div,它也有这个额外的空间,但是可以通过放置
height:0来缓解在清除分区上

此额外空间仅与
float:right一起出现

我使用的是HTML5 doctype,但也尝试过严格的doctype,在真正的IE7或模拟版本中没有效果

如何在保持自清除dom结构的同时删除底部的额外空间

下面的gif来自具有IE7仿真/兼容性的Windows 8.1 IE。这是你的电话号码

代码:
.block
{
背景:#888888;
/*Clearfix*/
缩放:1;
}
.有边际的东西
{
边缘底部:10px;
背景:#88dd88;
}
按钮
{
浮动:对;
/*使输入/按钮缩小到ie7中的正确大小*/
溢出:可见;
边缘底部:10px;
填充:0 8px;
背景#6666cc;
边界:0;
}
标题
{
背景:AAAAA;
边框底部:1px实心#000000;
}
这是目前唯一的IE7代码,只是为了显示这个问题。在IE7模式下查看它。

埃尼安秃鹫 Lorem ipsum dolor sit amet Ipsum dolor amet Lorem。
我没有找到解释,也没有其他人遇到同样的问题

但我找到了一个非常有效的解决方案,不幸的是,这个解决方案有点粗糙

将此缩放声明并排添加到
zoom:1.block
父元素上的code>。
表达式
(动态属性)值适用于IE7,并允许使用基本JavaScript

zoom:expression(this.runtimeStyle.zoom=“1”、this.appendChild(document.createElement(“br”)).style.cssText=“清除:两者;font:0/0 serif”)

来源:NBFC溢出入侵


完整的Clearfix: 我建议您使用条件样式表,而不是CSS属性破解(
*
),但我已经将它们保留了下来,因此它很好并且可以复制粘贴

.clearfix
{
    /* Clearfix: http://nicolasgallagher.com/better-float-containment-in-ie/ */
    /* for IE 6/7 */
    *zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif");
    /* non-JS fallback */
    *zoom: 1;
}

.clearfix:before,
.clearfix:after
{
    content: ' ';
    display: table;
}

.clearfix:after
{
    clear: both;
}
.block
{
背景:#888888;
/*Clearfix:http://nicolasgallagher.com/better-float-containment-in-ie/ */
/*对于IE 6/7*/
*zoom:expression(this.runtimeStyle.zoom=“1”、this.appendChild(document.createElement(“br”)).style.cssText=“清除:两者;font:0/0 serif”);
/*非JS回退*/
*缩放:1;
}
.布洛克:之前,
.布洛克:之后
{
内容:'';
显示:表格;
}
.布洛克:之后
{
明确:两者皆有;
}
.有边际的东西
{
边缘底部:10px;
背景:#88dd88;
}
按钮
{
浮动:对;
/*使输入/按钮缩小到ie7中的正确大小*/
溢出:可见;
边缘底部:10px;
填充:0 8px;
背景#6666cc;
边界:0;
}
标题
{
背景:AAAAA;
边框底部:1px实心#000000;
}

埃尼安秃鹫
Lorem ipsum dolor sit amet
Ipsum dolor amet Lorem。