html - 背景图像没有出现在ie

标签 html css

这适用于 firefox 和 chrome:

<div id="popup" style="display: block;">
        <div id="contentWrapper">

            <div id="popHeader">
                <span id="popupQuestion">The  nature.</span>
                <a id="popupYes" href="#"> </a>
                <a id="popupNo" href="/">Leave</a>
            </div>
        </div>
    </div>


#contentWrapper {
background-image: url("http://bestcamctory.com/images/warning/warning_bg.png");
height: 100%;
position: relative;
width: 100%;
}

但是在 ie 上没有显示背景图像。这是为什么?

最佳答案

如果您的子元素是绝对定位的,那么 #contentWrapper 就会折叠,因为在正常的文档流中没有元素可以告诉它应该有多高。 height: 100% 是相对的:该元素将仅与其父元素一样高,默认情况下也仅与其子元素(当前为 0)一样高。

您可以尝试一些方法来解决这个问题。

  • 将最小高度添加到 #contentWrapper(尝试从 1em 开始)
  • 移除一个或所有 child 的绝对定位 元素。

您也可以尝试向每个祖先元素添加 height: 100%

关于html - 背景图像没有出现在ie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13703461/

相关文章:

javascript - 具有固定纵横比 div 的居中图像的 Flexslider 幻灯片

javascript - anchor 链接到外部站点并避免显示为使用 javascript 的引用站点或流量源

html - 'aria-describedby' 属性是什么意思?

html - 背景不会显示在使用CSS的html页面中

html - 网页设计在桌面 PC 显示器中失真

css - 优化 HTML 中多余的 CSS 样式

c# - 如何在html表格中将水平行更改为垂直列数据显示

jquery - 如何在div中打洞?

javascript - 如何使用 JQuery 递归地为 DOM 子级设置样式值?

html - 我可以使用 html 或 css 进行图像方向检测吗?