新手練習,寫了一個無縫輪播。在火狐和IE11下都運行正常,在谷歌瀏覽器下第一次運行會出現(xiàn)某幾張圖片不顯示,但也沒具體的報錯信息,需要手動刷新幾次后才能正常顯示。
求教大家?guī)兔纯磫栴}出在哪里?谷歌瀏覽器:版本 64.0.3282.140(正式版本32 位)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Tab選項卡焦點圖</title>
<style>
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
#start {
display: block;
margin: 0 auto;
margin-top: 20px;
margin-bottom: 20px;
}
#banner {
width: 800px;
height: 450px;
margin: 50px auto;
position: relative;
overflow: hidden;
}
#banner_imgs {
width: 4800px;
position: absolute;
left: 0;
top: 0;
}
#banner_imgs li {
float: left;
}
#banner_imgs img {
width: 800px;
height: 100%;
display: block;
}
#left {
width: 0;
height: 0;
border-style: solid;
border-width: 20px 20px 20px 0;
border-color: transparent red;
position: absolute;
top: calc(50% - 20px);
left: 0;
background-color: RGBA(0, 0, 0, .3);
display: none;
}
#right {
border-style: solid;
border-width: 20px 0 20px 20px;
border-color: transparent red;
position: absolute;
top: calc(50% - 20px);
left: calc(100% - 20px);
background-color: RGBA(0, 0, 0, .3);
display: none;
}
#number {
width: 100%;
text-align: center;
position: absolute;
left: 0;
bottom: 20px;
}
#number a {
display: inline-block;
width: 20px;
border: 1px solid red;
height: 10px;
}
.number_color {
background-color: red;
}
#left:hover,
#right:hover {
background-color: RGBA(0, 0, 0, .7);
}
</style>
</head>
<body>
<input id="start" type="button" value="發(fā)送驗證碼">
<div id="banner">
<div id="banner_ul">
<ul id="banner_imgs">
<li>
<a href="javascript:">
<img src="https://youngfever.coding.me/jiaodian1.jpg" alt="">
</a>
</li>
<li>
<a href="javascript:">
<img src="https://youngfever.coding.me/jiaodian2.jpg" alt="">
</a>
</li>
<li>
<a href="javascript:">
<img src="https://youngfever.coding.me/jiaodian3.jpg" alt="">
</a>
</li>
<li>
<a href="javascript:">
<img src="https://youngfever.coding.me/jiaodian4.jpg" alt="">
</a>
</li>
<li>
<a href="javascript:">
<img src="https://youngfever.coding.me/jiaodian5.jpg" alt="">
</a>
</li>
</ul>
</div>
<div id="number">
<a class="number_color" href="javascript:"></a>
<a href="javascript:"></a>
<a href="javascript:"></a>
<a href="javascript:"></a>
<a href="javascript:"></a>
</div>
<div id="left"></div>
<div id="right"></div>
</div>
<script>
window.onload = function () {
var start = document.getElementById('start');
var countdown_number = 60;
var countdown_timer = null;
//倒計時
var banner_imgs = document.getElementById('banner_imgs');
var banner = document.getElementById('banner');
var number = document.getElementById('number');
var number_a = number.getElementsByTagName('a');
var left = document.getElementById('left');
var right = document.getElementById('right');
var index = 0;
var banner_imgs_width = banner_imgs.getElementsByTagName('img')[0].width;
var timer = '';
start.onclick = function () {
countdown_timer = setInterval(function () {
start.disabled = 'ture';
start.value = countdown_number-- + '秒后重試';
if (countdown_number === 0) {
start.disabled = '';
start.value = '發(fā)送驗證碼';
countdown_number = 60;
clearInterval(countdown_timer);
}
}, 500);
};
for (var y = 0; y < number_a.length; y++) {
number_a[y].id = y;
number_a[y].onmouseover = function () {
move(this.id, -banner_imgs_width);
index = Number(this.id);//此處有大坑,id默認類型是字符串類型,需要轉換;
}
}//設置index值和當前圖的值綁定
function click_type(click_type) {
if (click_type.onclick) {
if (click_type === right) {
if (index === 4) {
index = 0;
}
else {
index++
}
}
if (click_type === left) {
if (index === 0) {
index = 4;
}
else {
index--;
}
}
}
}//點擊函數(shù),根據(jù)左右點擊類型index值進行變化
function move(index_number, width) {
for (var i = 0; i < number_a.length; i++) {
banner_imgs.style.left = index_number * width + "px";
if (number_a[i].className === 'number_color') {
number_a[i].className = '';
}
number_a[index_number].className = 'number_color';
}
}//圖片移動位置和當前所顯示的紅點
banner.onmouseover = function () {
stop();
right.style.display = 'block';
left.style.display = 'block';
};
banner.onmouseout = function () {
play();
right.style.display = 'none';
left.style.display = 'none';
};
left.onclick = function () {
click_type(left);
move(index, -banner_imgs_width);
};
right.onclick = function () {
click_type(right);
move(index, -banner_imgs_width);
};
function play() {
timer = setInterval(
function () {
right.onclick();
}, 1500)
}
function stop() {
clearInterval(timer)
}
play();
}
</script>
</body>
</html>
北大青鳥APTECH成立于1999年。依托北京大學優(yōu)質雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學院和江蘇省首批服務外包人才培訓基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術與教育服務機構,發(fā)展為教育服務業(yè)的綜合性企業(yè)集團,成為集合面授教學培訓、網(wǎng)
達內(nèi)教育集團成立于2002年,是一家由留學海歸創(chuàng)辦的高端職業(yè)教育培訓機構,是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責任公司從事總經(jīng)理職務負責iOS教學及管理工作。
浪潮集團項目經(jīng)理。精通Java與.NET 技術, 熟練的跨平臺面向對象開發(fā)經(jīng)驗,技術功底深厚。 授課風格 授課風格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術顧問,美國Dachieve 系統(tǒng)架構師,美國AngelEngineers Inc. 系統(tǒng)架構師。