我正在一个网站上工作并且大部分都按照我想要的方式进行了规划,但我遇到了Internet Explorer 9(IE9)的一些格式问题。我已经通过论坛阅读了很多元素的定位,并且z-index和我如何解决我的问题。如果我在Chrome,Firefox,IE11中测试我的网站,一切看起来都不错。
然而,在IE9中(不确定大约10个)我的Overlay div隐藏在图像后面。我遇到问题的网站可以在http://ktwu.trilionstudios.com/wp-content/themes/ktwu/csstest.html找到我正在使用静态页面进行测试,但最终会将其移动到常规模板和动态生成的内容中。
<html>
<head>
<title>Test Page</title>
<style media="screen" type="text/css">
/*****CSS RESET*******/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, h7, h8, p, blockquote, pre, a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center,
dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; }
body { line-height: 1; }
ol, ul { list-style: none; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after,
q:before, q:after { content: ''; content: none; }
:focus { outline: 0; }
ins { text-decoration: none; }
del { text-decoration: line-through; }
table { border-collapse: collapse; border-spacing: 0; }
#slider4 ul, #slider4 li {
margin: 0px;
padding: 0px;
list-style: none;
}
#slider4 li {
height: 345px;
width: 960px;
float: left;
border: 1px solid red;
}
#homevideo .leftvideo{
position: relative;
height: 345px;
width: 650px;
float: left;
margin: 0px;
padding: 0px;
}
#homevideo a{
float: left;
display: block;
}
#homevideo .leftvideo img{
position: relative;
height: 345px;
width: 650px;
}
#homevideo .rightvideogroup{
float: right;
width: 300px;
}
#homevideo .rightvideo1 {
position: relative;
height: 168px;
width: 300px;
margin-bottom: 9px;
}
#homevideo .rightvideo2 {
position: relative;
height: 168px;
width: 300px;
}
#homevideo .rightvideo1 img{
position: relative;
width: 300px;
height: 168px;
}
#homevideo .rightvideo2 img{
position: relative;
width: 300px;
height: 168px;
}
#homevideo h3{
clear: both;
}
#homevideo .overlay {
position: absolute;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.83);
bottom: 5%;
left: 0px;
padding: 0% 0%;
width: 100%;
}
</style>
</head>
<body>
<div id="homevideo">
<div id="slider4">
<ul>
<li>
<div class="leftvideo">
<a href="http://watch.ktwu.org/video/2365060152"><img src="http://image.pbs.org/video-assets/KTWU/ktwu-special-programs/93697/images/Mezzanine_323.jpg" alt=""></a>
<div class="overlay">
<h4><a href="http://www.pbs.org/wgbh/masterpiece/">Sunflower Journeys</a></h4>
<h3><a href="http://watch.ktwu.org/video/2365143420">Wood, Brick, and Stone</a></h3>
</div>
</div>
<div class="rightvideogroup">
<div class="rightvideo1">
<a href="http://watch.ktwu.org/video/2365143420"><img src="http://image.pbs.org/video-assets/pbs/masterpiece/109334/images/Mezzanine_171.jpg" alt=""></a>
<div class="overlay">
<h4><a href="http://www.pbs.org/wgbh/masterpiece/">Masterpiece</a></h4>
<h3><a href="http://watch.ktwu.org/video/2365143420">Downton Abbey Season 4, Episode 1</a></h3>
</div>
</div>
<div class="rightvideo2">
<a href="http://watch.ktwu.org/video/2365145009"><img src="http://image.pbs.org/video-assets/KTWU/ktwu-ive-got-issues/109621/images/Mezzanine_142.jpg" alt=""></a>
<div class="overlay">
<h4><a href="http://www.ktwu.org/productions/ive-got-issues/">KTWU I've Got Issues</a></h4>
<h3><a href="http://watch.ktwu.org/video/2365145009">Philippine Calamity</a></h3>
</div>
</div>
</div>
<div class="clear"></div>
</li>
</ul>
</div>
</div>
</body>
</html>
谢谢,
大卫
答案 0 :(得分:0)
您似乎没有为 #homevideo .overlay 类添加z-index。
尝试:
#homevideo .overlay {
position: absolute;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.83);
bottom: 5%;
left: 0px;
padding: 0% 0%;
width: 100%;
z-index: 100;
}
您还应该在页面顶部添加doctype声明。我建议使用以下内容:
<!DOCTYPE html>
<html>
<head>
...