我在让 Chrome 和 Safari 正确显示容器图像上方的翻转 div 时遇到问题。我所做的有时会起作用,但是在调整页面大小时,您有时会看到翻转 div 和图像容器之间存在 1 或 2 个像素的小间隙。
我在这里做了一个演示:http: //jsfiddle.net/eJNsS/9/
截屏
HTML
<div id="related_projects">
<a href=# ><div class="thumbnail_image_related_project"><div id="image"><img width="300" height="173" src="http://www.gulfster.com/Lessern/Gulfsterhat.jpg" class="attachment-post-thumbnail wp-post-image" /></div><h2 class="transparent_font">IMG1</h2></div></a>
<a href=# ><div class="thumbnail_image_related_project"><div id="image"><img width="300" height="173" src="http://www.gulfster.com/Lessern/Gulfsterhat.jpg" class="attachment-post-thumbnail wp-post-image" /></div><h2 class="transparent_font">IMG2</h2></div></a>
<a href=# ><div class="thumbnail_image_related_project"><div id="image"><img width="300" height="173" src="http://www.gulfster.com/Lessern/Gulfsterhat.jpg" class="attachment-post-thumbnail wp-post-image" /></div><h2 class="transparent_font">IMG3</h2></div></a>
<a href=# ><div class="thumbnail_image_related_project"><div id="image"><img width="300" height="173" src="http://www.gulfster.com/Lessern/Gulfsterhat.jpg" class="attachment-post-thumbnail wp-post-image" /></div><h2 class="transparent_font">IMG4</h2></div></a>
<a href=# ><div class="thumbnail_image_related_project"><div id="image"><img width="300" height="173" src="http://www.gulfster.com/Lessern/Gulfsterhat.jpg" class="attachment-post-thumbnail wp-post-image" /></div><h2 class="transparent_font">IMG5</h2></div></a>
<a href=# ><div class="thumbnail_image_related_project"><div id="image"><img width="300" height="173" src="http://www.gulfster.com/Lessern/Gulfsterhat.jpg" class="attachment-post-thumbnail wp-post-image" /></div><h2 class="transparent_font">IMG6</h2></div></a>
<a href=# ><div class="thumbnail_image_related_project"><div id="image"><img width="300" height="173" src="http://www.gulfster.com/Lessern/Gulfsterhat.jpg" class="attachment-post-thumbnail wp-post-image" /></div><h2 class="transparent_font">IMG7</h2></div></a>
CSS
#related_projects {
background-color :#FFFF44;
margin-bottom: 20px;
position: relative;
top: 0;
left: 0;
overflow: hidden;
margin-bottom: 20px;
display: block;
margin-top: 2%;
}
#related_projects .thumbnail_image_related_project {
width: 23%;
position: relative;
float: left;
top: 0;
left: 0;
margin-left: 1%;
margin-right: 1%;
margin-top: 0%;
margin-bottom: 2%;
overflow: hidden;
line-height: 0;
}
#related_projects img {
width: 100% !important;
height: auto;
}
#related_projects p, #categories_container #left p {
text-align: left;
color: black;
font-family: HermL, Arial, sans-serif;
font-size: 17px;
line-height: 23px;
margin-bottom: 20px;
}
#link_description {
float: left;
width: 98%;
margin-left: 1%;
margin-right: 1%;
}
#link_description #link {
width: 50%;
float: right;
color: black;
font-family: HermL, Arial, sans-serif;
font-size: 17px;
line-height: 23px;
}
#link_description #link a {
color: #666666;
font-family: HermL, Arial, sans-serif;
font-size: 17px;
}
#link_description #link a:hover {
color: #22B573;
font-family: HermL, Arial, sans-serif;
font-size: 17px;
}
/* THUMBNAIL PICTURES
-------------------------------------------------------------- */
.thumbnail_image_related_project .transparent_font {
line-height: 1.25em;
position: absolute;
top: 0;
left: 0;
color: black;
background-color:white;
width: 92%;
padding-right: 3%;
height: 100%;
padding-left: 5%;
opacity:1;
filter: alpha(opacity=0);
}
.thumbnail_image_related_project h2 {
padding-top: 30px;
text-align: left;
color: black;
font-family: HermL, Arial, sans-serif;
font-size: 17px;
line-height: 23px;
}
h2 {
margin:0px;
}
jQuery
$("#slider").hover(
function(){
$(".caption").stop().animate({'opacity' : '0.9'}, 200);
},
function(){
$(".caption").stop().animate({'opacity' : '0'}, 100);
}
);
$(".thumbnail_image_related_project").hover(
function(){
$(this).children(".transparent_font").stop()
.animate({'opacity' : '0.7', 'padding-top': '10px'}, 300);
},
function(){
$(this).children(".transparent_font").stop()
.animate({'opacity' : '0', 'padding-top': '30px'}, 300);
}
);
感谢您的帮助