87,997
社区成员




<style type="text/css">
#banner {position:relative; height:100%; overflow:hidden; }
#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; z-index:1002;
margin:0; padding:0; bottom:10%; left:50%;}
#banner ul li { padding:0px 8px;float:left;display:block;color:#FFF;background:#6f4f67;cursor:pointer}
#banner ul li.on { background:#900}
#banner_list img {border:0px; width:100%;}
#banner_list a{position:absolute;}
</style>
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
var t = n = 0, count;
$(document).ready(function(){
count=$("#banner_list a").length;
$("#banner_list a:not(:first-child)").hide();
$("#banner li").click(function() {
var i = $(this).text() - 1;
n = i;
if (i >= count) return;
$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
document.getElementById("banner").style.background="";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
t = setInterval("showAuto()", 3000);
$("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});
})
function showAuto()
{
n = n >=(count - 1) ? 0 : ++n;
$("#banner li").eq(n).trigger('click');
}
</script>
</head>
<body scrollbars="no" scroll="no">
<div style="position:absolute; top:0; left:0; width:100%; height:100%; background:url(imgs/fullbody.png);">
<div id="banner">
<ul>
<li class="on">1</li>
<li>2</li>
</ul>
<div id="banner_list">
<a><img src="imgs/main-1.jpg" /></a>
<a><img src="imgs/main-2.jpg" /></a>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
html,body{width:100%;height:100%}
#banner {position:relative; height:100%; overflow:hidden; }
#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; z-index:1002;
margin:0; padding:0; bottom:10%; left:50%;}
#banner ul li { padding:0px 8px;float:left;display:block;color:#FFF;background:#6f4f67;cursor:pointer}
#banner ul li.on { background:#900}
#banner_list img {border:0px; width:100%;}
#banner_list a{position:absolute;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var t = n = 0, count;
$(document).ready(function(){
count=$("#banner_list a").length;
var bw=$('body').width(),bh=$('body').height();
$('#banner_list img').load(function(){
resizeImg(this);
var p=$(this).parent();
if(p.index())p.hide();
});
$('#banner_list img').each(function(i){
resizeImg(this);
if(this.offsetWidth && i)$(this).parent().hide();
});
function resizeImg(img){
if(!img.offsetWidth ) return;
var img=$(img),w=img.width(),h=img.height();
if(bh<h){
w=parseInt(bh/h*w);
h=bh;
}else if(bw<w){
h=parseInt(bw/w*h);
w=bw;
}else{
if(w>h){
h=parseInt(bw/w*h);
w=bw;
}else{
w=parseInt(bh/h*w);
h=bh;
}
}
img.css({
width:w,
height:h
});
img.parent().css({
left: (bw-w)>>1,
top: (bh-h)>>1
});
}
$("#banner li").click(function() {
var i = $(this).text()-1;
n = i;
if (i >= count) return;
$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
//document.getElementById("banner").style.background="";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
//t = setInterval("showAuto()", 3000);
// $("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});
})
// function showAuto()
// {
// n = n >=(count - 1) ? 0 : ++n;
// $("#banner li").eq(n).trigger('click');
// }
</script>
</head>
<body scrollbars="no" scroll="no">
<div style="position:absolute; top:0; left:0; width:100%; height:100%; background:url(imgs/fullbody.png) #aaa;">
<div id="banner">
<ul>
<li class="on">1</li>
<li>2</li>
</ul>
<div id="banner_list">
<a><img src="http://img.hb.aicdn.com/707cb9414334425845c2768b97e1766889ce5a1129c88-LRF7jf_fw554" /></a>
<a><img src="http://imgsrc.baidu.com/forum/pic/item/aefd5266d016092443074862d40735fae6cd34ad.jpg" /></a>
</div>
</div>
</div>
</body>
</html>
<style type="text/css">
#banner {position:relative; height:100%; overflow:hidden; }
#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; z-index:1002;
margin:0; padding:0; bottom:10%; left:50%;}
#banner ul li { padding:0px 8px;float:left;display:block;color:#FFF;background:#6f4f67;cursor:pointer}
#banner ul li.on { background:#900}
#banner_list img {border:0px; width:100%;}
#banner_list a{position:absolute;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var t = n = 0, count;
$(document).ready(function(){
count=$("#banner_list a").length;
var bw=$('body').width(),bh=$('body').height();
$('#banner_list img').each(function(i){this.index=i})
$('#banner_list img').load(function(){
resizeImg(this);
var p=$(this).parent();
if(p.index())p.hide();
});
function resizeImg(img){
var img=$(img),w=img.width(),h=img.height(),aw,ah;
if(bh<h){
w=parseInt(bh/h*w);
h=bh;
}else if(bw<w){
h=parseInt(bw/w*h);
w=bw;
}else{
if(w>h){
h=parseInt(bw/w*h);
w=bw;
}else{
w=parseInt(bh/h*w);
h=bh;
}
}
img.css({
width:w,
height:h
});
img.parent().css({
left: (bw-w)>>1,
top: (bh-h)>>1
});
}
$("#banner li").click(function() {
var i = $(this).text() - 1;
n = i;
if (i >= count) return;
$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
//document.getElementById("banner").style.background="";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
//t = setInterval("showAuto()", 3000);
// $("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});
})
// function showAuto()
// {
// n = n >=(count - 1) ? 0 : ++n;
// $("#banner li").eq(n).trigger('click');
// }
</script>
</head>
<body scrollbars="no" scroll="no">
<div style="position:absolute; top:0; left:0; width:100%; height:100%; background:url(imgs/fullbody.png) #aaa;">
<div id="banner">
<ul>
<li class="on">1</li>
<li>2</li>
</ul>
<div id="banner_list">
<a><img src="http://img.hb.aicdn.com/707cb9414334425845c2768b97e1766889ce5a1129c88-LRF7jf_fw554" /></a>
<a><img src="http://imgsrc.baidu.com/forum/pic/item/aefd5266d016092443074862d40735fae6cd34ad.jpg" /></a>
</div>
</div>
</div>
</body>
</html>
#banner_list img {border:0px; width:100%;min-height: expression(document.documentElement.clientHeight + "px"); margin-left:expression((document.documentElement.clientWidth-this.Width)/2 + "px"); margin-top:expression((document.documentElement.clientHeight-this.Height)/2 + "px"); }
这个方法好像可以计算位置固定,但是要如何获取图片的高度和宽度??? 我用了this.clientWidth就出错了min-height: expression(document.documentElement.clientHeight + "px");
现在的效果是不管网页多大多宽,图片都是等比例放大或者缩小的全屏
剩下最后一步了,如何让图片永远水平居中和垂直居中
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
html,body{width:100%;height:100%}
#banner {position:relative; height:100%; overflow:hidden; }
#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; z-index:1002;
margin:0; padding:0; bottom:10%; left:50%;}
#banner ul li { padding:0px 8px;float:left;display:block;color:#FFF;background:#6f4f67;cursor:pointer}
#banner ul li.on { background:#900}
#banner_list img {border:0px; width:100%;}
#banner_list a{position:absolute;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var t = n = 0, count;
$(document).ready(function(){
count=$("#banner_list a").length;
var bw=$('body').width(),bh=$('body').height();
$('#banner_list img').load(function(){
resizeImg(this);
var p=$(this).parent();
if(p.index())p.hide();
});
$('#banner_list img').each(function(i){
resizeImg(this);
if(this.offsetWidth && i)$(this).parent().hide();
});
function resizeImg(img){
if(!img.offsetWidth ) return;
var img=$(img),w=img.width(),h=img.height();
console.log( [w,h] );
if(bh<h){
w=parseInt(bh/h*w);
h=bh;
}else if(bw<w){
h=parseInt(bw/w*h);
w=bw;
}else{
if(w>h){
h=parseInt(bw/w*h);
w=bw;
}else{
w=parseInt(bh/h*w);
h=bh;
}
}
img.css({
width:w,
height:h
});
img.parent().css({
left: (bw-w)>>1,
top: (bh-h)>>1
});
}
$("#banner li").click(function() {
var i = $(this).text()-1;
n = i;
if (i >= count) return;
$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
//document.getElementById("banner").style.background="";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
//t = setInterval("showAuto()", 3000);
// $("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});
})
// function showAuto()
// {
// n = n >=(count - 1) ? 0 : ++n;
// $("#banner li").eq(n).trigger('click');
// }
</script>
</head>
<body scrollbars="no" scroll="no">
<div style="position:absolute; top:0; left:0; width:100%; height:100%; background:url(imgs/fullbody.png) #aaa;">
<div id="banner">
<ul>
<li class="on">1</li>
<li>2</li>
</ul>
<div id="banner_list">
<a><img src="http://img.hb.aicdn.com/707cb9414334425845c2768b97e1766889ce5a1129c88-LRF7jf_fw554" /></a>
<a><img src="http://imgsrc.baidu.com/forum/pic/item/aefd5266d016092443074862d40735fae6cd34ad.jpg" /></a>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
html,body{width:100%;height:100%}
#banner {position:relative; height:100%; overflow:hidden; }
#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; z-index:1002;
margin:0; padding:0; bottom:10%; left:50%;}
#banner ul li { padding:0px 8px;float:left;display:block;color:#FFF;background:#6f4f67;cursor:pointer}
#banner ul li.on { background:#900}
#banner_list img {border:0px; width:100%;}
#banner_list a{position:absolute;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var t = n = 0, count;
$(document).ready(function(){
count=$("#banner_list a").length;
var bw=$('body').width(),bh=$('body').height();
//console.info( [bw,bh] );
$('#banner_list img').load(function(){
resizeImg(this);
var p=$(this).parent();
if(p.index())p.hide();
});
$('#banner_list img').each(resizeImg);
function resizeImg(img){
if(!img.offsetWidth ) return;
var img=$(img),w=img.width(),h=img.height(),aw,ah;
if(bh<h){
w=parseInt(bh/h*w);
h=bh;
}else if(bw<w){
h=parseInt(bw/w*h);
w=bw;
}else{
if(w>h){
h=parseInt(bw/w*h);
w=bw;
}else{
w=parseInt(bh/h*w);
h=bh;
}
}
img.css({
width:w,
height:h
});
img.parent().css({
left: (bw-w)>>1,
top: (bh-h)>>1
});
}
$("#banner li").click(function() {
var i = $(this).text() - 1;
n = i;
if (i >= count) return;
$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
//document.getElementById("banner").style.background="";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
//t = setInterval("showAuto()", 3000);
// $("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});
})
// function showAuto()
// {
// n = n >=(count - 1) ? 0 : ++n;
// $("#banner li").eq(n).trigger('click');
// }
</script>
</head>
<body scrollbars="no" scroll="no">
<div style="position:absolute; top:0; left:0; width:100%; height:100%; background:url(imgs/fullbody.png) #aaa;">
<div id="banner">
<ul>
<li class="on">1</li>
<li>2</li>
</ul>
<div id="banner_list">
<a><img src="http://img.hb.aicdn.com/707cb9414334425845c2768b97e1766889ce5a1129c88-LRF7jf_fw554" /></a>
<a><img src="http://imgsrc.baidu.com/forum/pic/item/aefd5266d016092443074862d40735fae6cd34ad.jpg" /></a>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
#banner {position:relative; height:100%; overflow:hidden; }
#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; z-index:1002;
margin:0; padding:0; bottom:10%; left:50%;}
#banner ul li { padding:0px 8px;float:left;display:block;color:#FFF;background:#6f4f67;cursor:pointer}
#banner ul li.on { background:#999}
#banner_list img {border:0px; width:100%; height:100%; min-height: expression(document.documentElement.clientHeight + "px");}
#banner_list a{position:absolute;}
</style>
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
var t = n = 0, count;
$(document).ready(function(){
count=$("#banner_list a").length;
$("#banner_list a:not(:first-child)").hide();
$("#banner li").click(function() {
var i = $(this).text() - 1;
n = i;
if (i >= count) return;
$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
document.getElementById("banner").style.background="";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
t = setInterval("showAuto()", 30000);
$("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 30000);});
})
function showAuto()
{
n = n >=(count - 1) ? 0 : ++n;
$("#banner li").eq(n).trigger('click');
}
</script>
</head>
<body scrollbars="no" scroll="no" onresize="myLoad()" onload="myLoad()" style="margin:0 auto">
<div style="position:absolute; top:0; left:0; width:100%; height:100%; background:url(imgs/fullbody.png);">
<div id="banner">
<ul>
<li class="on">1</li>
<li>2</li>
</ul>
<div id="banner_list">
<a><img src="imgs/main-1.jpg" /></a>
<a><img src="imgs/main-2.jpg"/></a>
</div>
</div>
</div>
</body>
</html>