新人,代码有什么不规范的还请提示一下
还有为什么结果是先弹窗再执行函数
<!DOCTYPE html>
<HTML>
<head>
<script>
window.onload = function () {
basecss();
alert("yes");
}
function basecss(){
//slier樣式
var slider = document.getElementById("slider");
slider.style.padding="0px";
slider.style.height="480px";
slider.style.width="1024px";
slider.style.margin="auto";
slider.style.marginTop="70px";
slider.style.backgroundColor="red";
var img =document.getElementsByClassName("sliderimg");
//slierimg样式
for(var i=0;i<5;i++){
img[i].style.width="200px";
img[i].style.height="350px";
img[i].style.backgroundColor="blue";
img[i].style.padding="0px";
img[i].style.position="relative";
img[i].style.float= "left";
img[i].style.top= "60px";
img[i].style.left= "12px";
if( i=0 || i =4){
img[i].style.transform="scale(0.75,0.75);"
}
}
}
</script>
</head>
<body>
<img id = "test"> - - --- -</img>
<div id="slider">
<img class="sliderimg">
<img class="sliderimg">
<img class="sliderimg">
<img class="sliderimg">
<img class="sliderimg">
</div>
</body>
</HTML>