0
我嘗試製作垂直/水平居中的流體幻燈片,但似乎是這樣,幻燈片不在Internet Explorer 7中垂直居中,並且Internet Explorer 9和10存在一些問題。有人可以幫助我改進我的代碼。 垂直中心的頂部和底部邊緣也有一些像素差異。垂直/水平居中的流體幻燈片
感謝
工作例如:http://goo.gl/DesJo
PS:有沒有辦法提前下載所有圖像?
HTML:
<div id="content">
<article class="layer">
<div class="wrap">
<ul class="rslides">
<li><img src="01.jpg" alt=""></li>
<li><img src="02.jpg" alt=""></li>
<li><img src="03.jpg" alt=""></li>
<li><img src="04.jpg" alt=""></li>
<li><img src="05.jpg" alt=""></li>
<li><img src="06.jpg" alt=""></li>
<li><img src="07.jpg" alt=""></li>
<li><img src="08.jpg" alt=""></li>
<li><img src="09.jpg" alt=""></li>
</ul>
</div>
</article>
<article class="layer"></article>
</div>
的JavaScript:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/resize.js"></script>
<script src="js/responsiveslides.min.js"></script>
<script>
$(function() {
$(".rslides").responsiveSlides({
fx: 'fade',
speed: 0,
timeout: 3000,
random: true
});
});
</script>
resize.js
/*window.onresize = function(){
$('article.layer img').css({
maxHeight: $('article.layer').height() * 0.8,
maxWidth: $('article.layer').width() * 0.8
});
};*/
$(window).resize(function(){
$('article.layer img').css({
maxHeight: $('article.layer').height() * 0.8,
maxWidth: $('article.layer').width() * 0.8
});
});
CSS(wihtout CSSreset和菜單)
body {
font-family: 'theantiquab_w5_plainregular';
color: #000;
}
a {
text-decoration: none;
color: #000;
}
a:hover {
color: #e84a36;
}
@font-face {
font-family: 'theantiquab_w5_plainregular';
src: url('theantiqua-webfont.eot');
src: url('theantiqua-webfont.eot?#iefix') format('embedded-opentype'), url('theantiqua-webfont.woff') format('woff'), url('theantiqua-webfont.ttf') format('truetype'), url('theantiqua-webfont.svg#theantiquab_w5_plainregular') format('svg');
font-weight: normal;
font-style: normal;
}
article, aside, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
html, body, #content {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
overflow: hidden;
}
article.layer {
position: relative;
display: table;
height: 100%;
width: 100%;
}
div.wrap {
display: table-cell;
vertical-align: middle;
text-align: center;
}
article.layer img {
max-width: 80%;
max-height: 80%;
}
/* http://responsive-slides.viljamis.com */
.rslides {
display: inline-block;
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 0;
}
.rslides li {
position: absolute;
display: none;
width: 100%;
left: 0;
top: 0;
}
.rslides li:first-child {
position: relative;
float: left;
}
.rslides img {
height: auto;
border: 0;
}
感謝。 jQuery的預加載工作非常好,但似乎IE7黑客無法正常工作。你知道一個不同的/更好的方式來垂直/水平中心流體幻燈片? – user1939490
IE 7及以下版本不支持顯示錶*所以你應該爲它們創建一個表格元素但是這不適合使用html表格 – Loris
你是對的!我認爲最好不要使用技巧/黑客。我會忽略IE7。 – user1939490