如果想做一個全屏的輪播,應(yīng)該怎么控制container這個div的大小或者圖片的大小,使之適應(yīng)不同瀏覽器不同電腦呢
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>以太工作室</title>
<link href="css/top.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/picture.js"></script>
</head>
<body>
<div id="top">
<div>
<img src="img/logo.jpg" height="100px">
</div>
<ul>
<li><a href="html/gaikuang.html">工作室概況</a>
<ul>
<li><a href="#">成員信息</a></li>
<li><a href="#">發(fā)展歷程</a></li>
<li><a href="#">團隊合租</a></li>
</ul>
</li>
<li><a href="#">內(nèi)部機構(gòu)</a>
<ul>
<li><a href="#">前端</a></li>
<li><a href="#">后臺</a></li>
<li><a href="#">視頻編輯</a></li>
</ul>
</li>
<li><a href="#">學(xué)術(shù)研究</a>
<ul>
<li><a href="#">前端技術(shù)</a></li>
<li><a href="#">后臺交流</a></li>
<li><a href="#">視頻</a></li>
</ul>
</li>
<li><a href="#">項目聯(lián)系</a></li>
</ul>
<div>
<div style=""></div>
<div>考生·在校生·教職工
<img src="img/59f532dba2f2d584e683e7fcf5aff005.png" height="20"></div>
<div>信息門戶
<img src="img/19e7f62b1b56b4f4348a3e2267967b74.png" height="20"></div>
<div>OA系統(tǒng)
<img src="img/4f3c6bc9e42131eb7e7909326bfa8c57.png" height="20"></div>
<div>信息公開
<img src="img/8d270c434aa4fc40ba17d13f0497035a.png" height="20"></div>
<div>En</div>
<div>
<form>
<input id="research" type="text" value="搜索" /></form>
</div>
</div>
</div>
<div id="wpic">
<div id="wleft">
<a href="#">
<div id="wlxpic">成員培養(yǎng)</div>
</a>
<a href="#">
<div id="wlxpic">招員納新</div>
</a>
<a href="#">
<div id="wlxpic">小組討論</div>
</a>
<a href="#">
<div id="wlxpic">作品展示</div>
</a>
</div>
<div id="wmiddle">
<p>新聞通知</p>
<ul>
<li>
<a href="#"> <span style="float: left;color: #15C7A7;">|</span>新聞一</a>
</li><span>2015-5-13</span>
<li>
<a href="#"> <span style="float: left;color: #15C7A7;">|</span>新聞一</a>
</li><span>2015-5-13</span>
<li>
<a href="#"> <span style="float: left;color: #15C7A7;">|</span>新聞一</a>
</li><span>2015-5-13</span>
<li>
<a href="#"> <span style="float: left;color: #15C7A7;">|</span>新聞一</a>
</li><span>2015-5-13</span>
<li>
<a href="#"> <span style="float: left;color: #15C7A7;">|</span>新聞一</a>
</li><span>2015-5-13</span>
</ul>
</div>
<div id="wright">
<a href="#">
<div id="wrxpic">信息公告</div>
</a>
<a href="#">
<div id="wrxpic">公共服務(wù)</div>
</a>
<a href="#">
<div id="wrxpic">交流合作</div>
</a>
<a href="#">
<div id="wrxpic">成就展示</div>
</a>
</div>
</div>
<div id="container">
<div id="list" style="left: -1920px">
<img src="img/凈月彩虹.jpg">
<img src="img/cd8edb2d6263e99c1b590cfeadd58db6.jpg">
<img src="img/本部圖書館.jpg">
<img src="img/本部首面.jpg">
<img src="img/6f9eae6d32f743d460daf81e868cecbd.jpg">
<img src="img/本部圖書館.jpg">
<img src="img/cd8edb2d6263e99c1b590cfeadd58db6.jpg">
</div>
<a href="javascript:void(0)" id="prev"><</a>
<a href="javascript:void(0)" id="next">></a>
</div>
<div id="footer">
<p><a href="#">聯(lián)系我們</a> | <a href="#">加入我們</a></p>
<p>版權(quán)所有© 以太工作室 地址: 長春市凈月大街2555號 郵編130000</p>
</div>
</body>
</html>
以下是js部分
function gid(id) {
return document.getElementById(id);
}
window.onload = function() {
var container= gid("container");
var list = gid("list");
var prev = gid("prev");
var next = gid("next");
var timer;
//位移函數(shù),每次移動offset
function animate(offset) {
var newLeft = parseInt(list.style.left) + offset;
list.style.left = newLeft + 'px';
list.style.left = check(parseInt(list.style.left)) + 'px';
}
//檢測函數(shù) ?保證圖片輪播正常
function check(left) {
if (left > -1920) return -7680;
if (left < -7680) return -1920;
}
//點擊箭頭切換頁面,調(diào)用animate函數(shù)
prev.onclick = function() {
animate(1920);
}
next.onclick = function() {
animate(-1920);
}
// 定時器 自動播放效果,3秒自動播放一次
function play() {
timer = setInterval(next.onclick, 3000);
}
function stop() {
clearInterval(timer);
}
container.onmouseover = stop;
container.onmouseout = play;
play();
}
以下是css:
* {
margin: 0px;
padding: 0px;
}
body {
margin: 0;
padding: 0;
font-family: "微軟雅黑";
height: 620px;
}
#container {
width: 100%;
height: 620px;
overflow: hidden;
position: relative;
top: -310px;
left: 0px;
z-index: -3;
}
#list img {
width: 1920px;
height: 620px;
float: left;
}
#list {
position: absolute;
width: 9600px;
}
.arrow {
height: 35px;
width: 35px;
/*opacity: 0.3;*/
background-color: rgba(0, 0, 0, 0.3);
display: none;
/*display: block;*/
color: white;
text-decoration: none;
font-size: 30px;
text-align: center;
position: absolute;
font-weight: bold;
z-index: 2;
}
#prev {
left: 5px;
top: 0;
bottom: 0;
margin: auto;
}
#next {
right: 5px;
top: 0;
bottom: 0;
margin: auto;
}
.arrow: hover {
background-color: rgba(0, 0, 0, 0.7);
}
#top {
height: 100px;
background: #333;
/*opacity: 0.3;*/
color: whitesmoke;
font-weight: bolder;
background-color: rgba(0, 0, 0, 0.5);
}
.logo {
float: left;
margin: 0;
z-index: 1000;
}
#top ul li {
float: left;
list-style: none;
height: 100px;
/*width:10%;*/
margin: 0;
border-right: 1px solid white;
text-align: center;
display: block;
line-height: 100px;
}
/*#top ul{
position: relative;
}*/
#top ul li ul {
/*position: absolute;*/
left: 276px;
/*height: 100px;*/
line-height: 0px;
text-align: center;
padding-left: 0px;
display: none;
}
#top ul li ul li {
float: none;
/*width: 100%;*/
height: 37px;
line-height: 25px;
}
#top ul li ul li a {
color: black;
}
#top ul li ul li a:hover {
/*width: 50px;*/
height: 31px;
color:blanchedalmond;
padding-top: 5px;
}
#top ul li:hover ul {
display: block;
background-color: rgba(255, 255, 255, 0.5);
}
#top a {
text-decoration: none;
color: black;
display: block;
padding: 0px 18px;
color: white;
}
#top a:hover {
color: white;
background-color: rgba(59, 160, 247, 0.5);
}
.Xss {
float: right;
margin-top: 12px;
}
.Xselect {
margin-top: 5px;
float: left;
border: 1px solid white;
height: 30px;
line-height: 30px;
margin: 0;
padding: 0 10px;
}
.select {
position: absolute;
top: 70px;
right: 20px;
}
#research {
color: #fffefe;
height: 20px;
width: 150px;
background: rgba(0, 0, 0, 0);
padding: 5px;
margin-bottom: -15px;
}
#wpic {
width: 815px;
height: 205px;
/*background-color: black;*/
position: relative;
top: 160px;
z-index: 2;
margin-left: auto;
margin-right: auto;
}
#wleft {
width: 204px;
/*margin-left: 10px;*/
text-align: center;
line-height: 100px;
color: white;
}
#wleft a {
color: white;
}
#wlxpic {
width: 100px;
height: 100px;
background-color: rgba(18, 169, 226, 0.7);
float: left;
margin-top: 2px;
margin-right: 2px;
}
#wlxpic:hover {
background-color: rgba(72, 68, 68, 0.6);
color: white
}
#wright {
width: 204px;
float: right;
margin-top: -102px;
line-height: 100px;
color: white;
text-align: center;
}
#wrxpic {
width: 100px;
height: 100px;
background-color: rgba(18, 169, 226, 0.7);
float: right;
margin-top: 2px;
margin-right: 2px;
}
#wright a {
color: white;
}
#wrxpic:hover {
background-color: rgba(72, 68, 68, 0.6);
color: white
}
#wmiddle {
width: 389px;
height: 202px;
margin: 1px;
background-color: rgba(255, 255, 255, 0.7);
float: left;
margin-top: -100px;
margin-left: 8px;
margin-right: 5px;
border-top: 2px solid #12A9E2;
}
#wmiddle p {
font-weight: bold;
color: #1C71CA;
font-size: 18px;
line-height: 25px;
margin-left: 10px;
margin-top: 5px;
}
#wmiddle ul {
list-style: none;
margin-left: 20px;
margin-top: 20px;
}
#wmiddle a {
display: block;
color: black;
line-height: 29px;
text-decoration: none;
}
#wmiddle a:hover {
color: #0A89D4;
}
.span2 {
display: block;
float: right;
color: blue;
margin-right: 10px;
line-height: 20px;
margin-top: -24px;
}
.span1 {
float: left;
font-weight: bolder;
margin-right: 5px;
line-height: 25px;
}
#footer {
height: 70px;
z-index: 2;
background-color: rgba(0, 0, 0, 0.7);
width: 100%;
position: fixed;
bottom: 0px;
}
#footer p {
text-align: center;
color: white;
line-height: 28px;
}
#footer a {
text-decoration: none;
color: white;
}
#footer a:hover {
color: #0A89D4;
}
2016-07-21
設(shè)置container與圖片大小一致,也就是全屏寬度,list的寬度=圖片寬度*n張圖片
2016-06-10
其實我覺得你直接用corelDRAW或者其他圖片編輯的一些軟件直接把圖片拉大不是更省事么......
2016-06-08
用百分比去控制
2016-05-29
控制圖片大小不就行啦