87,996
社区成员
发帖
与我相关
我的任务
分享




<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>FadeIn Test</title>
<style>
div {
display: none;
text-align: center;
line-height: 85px;
font-size: 48px;
position: absolute;
border: 1px #CCCCCC solid;
width: 300px;
height: 85px;
margin-left: 100px;
background-color: #FFFFCC;
vertical-align: middle;
}
.one {
top: 0;
}
.two {
top: 100px;
}
.three {
top: 200px;
}
</style>
<script type="text/javascript" src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("button").click(function () {
$(".one").fadeIn();
$(".two").fadeIn("slow");
$(".three").fadeIn(3000);
})
})
</script>
</head>
<body>
<button>点击淡入</button>
<div class="one">div1</div>
<div class="two">div2</div>
<div class="three">div3</div>
</body>
</html>
我在这里看的https://www.w3school.com.cn/jquery/jquery_fade.asp
和你上面那个差不多
我这和你写的那个代码也差不多 实在看不出哪里错了
https://www.w3school.com.cn/jquery/jquery_fade.asp
<style>
.one {display:block;
float:left;
border:1px #CCCCCC solid;
width:300px;
height:85px;
margin-left:300px;
background-color:#FFFFCC;}
.two {display:block;
position:absolute;
border:1px #CCCCCC solid;
width:300px;
height:85px;
text-align:center;
margin-left:300px;
margin-top:100px;
background-color:#FFFFCC;}
.three {display:block;
position:absolute;
border:1px #CCCCCC solid;
width:300px;
height:85px;
text-align:center;
margin-left:300px;
margin-top:200px;
background-color:#FFFFCC;}
</style>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$(".one").fadeIn();
$(".two").fadeIn("slow");
$(".three").fadeIn(3000);
})
})
</script>
</head>
<body>
<button>点击淡入</button>
<div class="one">div1</div>
<div class="two">div2</div>
<div class="three">div3</div>
</body>
</html>
可以看清吗 排版有点乱
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000);
});
});
</script>
</head>
<body>
<p>以下实例演示了 fadeIn() 使用了不同参数的效果。</p>
<button>点击淡入 div 元素。</button>
<br><br>
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div><br>
<div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div><br>
<div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div>
</body>
</html>
学jquery的话到这来学:https://www.runoob.com/jquery/jquery-tutorial.html