Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.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
Html IE7-背景颜色太宽_Html_Css_Internet Explorer 7 - Fatal编程技术网

Html IE7-背景颜色太宽

Html IE7-背景颜色太宽,html,css,internet-explorer-7,Html,Css,Internet Explorer 7,我有一些文字在图像的顶部 在新浏览器中,它运行良好 但当我签入IE7时,它看起来是这样的: 不知何故,IE7非常热衷于给背景色一个100%的宽度。 我不想通过设置宽度来解决这个问题,因为文本的长度会随页面的不同而变化 我的CSS如下所示: #sub-slideshow-wrapper h2 { font-family: 'Droid Sans',sans-serif; display: table; font-size: 20px; font-weight: 900; color: #000;

我有一些文字在图像的顶部

在新浏览器中,它运行良好

但当我签入IE7时,它看起来是这样的:

不知何故,IE7非常热衷于给背景色一个100%的宽度。 我不想通过设置宽度来解决这个问题,因为文本的长度会随页面的不同而变化

我的CSS如下所示:

#sub-slideshow-wrapper h2 {
font-family: 'Droid Sans',sans-serif;
display: table;
font-size: 20px;
font-weight: 900;
color: #000;
background: #e68e47; 
background: rgba(230,142,71,0.8);
padding: 7px;
margin: 0 0 3px 0;
}
我知道IE7已经过时了,只有1.xxx在使用它。但我希望它能在所有浏览器上运行,即使是旧的浏览器

如您所见,IE7不支持
display:table
,因此您的
h2
使用
display:block
(h2的标准
display
)进行渲染,从而导致您的问题


由于IE7的全球使用率约为0.1%,我建议您保持原样。

如果您必须支持IE7,请添加zoom:1和*display:inline(star hack to target IE6和IE7),使IE7将其显示为内联块但这可能会产生您不想要的其他效果。

#sub-slideshow-wrapper h2 {
font-family: 'Droid Sans',sans-serif;

zoom: 1; /* added */
*display: inline; /* added */

display: table;
font-size: 20px;
font-weight: 900;
color: #000;
background: #e68e47; 
background: rgba(230,142,71,0.8);
padding: 7px;
margin: 0 0 3px 0;
}

display:table
不受IE7支持-我不支持。我有一本书。但是我现在是唯一的一个,在有另一个之前。谢谢:)我只是不喜欢有人在没有说明原因的情况下否决我的答案;)