2 回答

TA貢獻27條經驗 獲得超4個贊
<html>
<head>
? ?<title></title>
? ?<script src="js/jquery-1.8.0.min.js" type="text/javascript"></script>
? ?<style type="text/css">
? ? ? ?body{
? ? ? ? ? ?margin:0;
? ? ? ? ? ?padding:0;
? ? ? ? ? ?background:url(img/house_type.jpg) no-repeat;
? ? ? ? ? ?background-size:100% 800px;
? ? ? ?}
? ? ? ?.kuai{
? ? ? ? ? ?width:1800px;
? ? ? ? ? ?height:800px;
? ? ? ? ? ?position:relative;
? ? ? ? ? ?margin:0 auto;
? ? ? ?}
? ? ? ?.kuai1,.kuai2,.kuai3{
? ? ? ? ? ?position:absolute;
? ? ? ? ? ?width:400px;
? ? ? ? ? ?height:600px;
? ? ? ? ? ?top:100px;
? ? ? ?}
? ? ? ?.kuai1{
? ? ? ? ? ?background:url(img/zufang_gongyu.jpg) no-repeat;
? ? ? ? ? ?background-size:cover;
? ? ? ? ? ?left:0px;
? ? ? ? ? ?top:150px;
? ? ? ? ? ?z-index:-100;
? ? ? ?}
? ? ? ?.kuai2{
? ? ? ? ? ?background:url(img/zufang_map.jpg) no-repeat;
? ? ? ? ? ?background-size:cover;
? ? ? ? ? ?height:700px;
? ? ? ? ? ?width:500px;
? ? ? ? ? ?left:650px;
? ? ? ? ? ?z-index:0;
? ? ? ?}
? ? ? ?.kuai3{
? ? ? ? ? ?background:url(img/villa.jpg) no-repeat;
? ? ? ? ? ?background-size:cover;
? ? ? ? ? ?left:1400px;
? ? ? ? ? ?top:150px;
? ? ? ? ? ?z-index:100;
? ? ? ?}
? ?</style>
</head>
<body>
<div class="kuai">
? ?<div class="kuai1" data="0"></div>
? ?<div class="kuai2" data="1"></div>
? ?<div class="kuai3" data="2"></div>
</div>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">
? ?$(document).ready(function(){
? ? ? ?setInterval(function(){
? ? ? ? ? ?$("[data='0']").animate({top:"150px",left:"1400px",width:"400px",height:"600px"}, 2000,function(){
? ? ? ? ? ? ? ?$(this).css({"z-index":100}).attr("data",2);
? ? ? ? ? ?})
? ? ? ? ? ?$("[data='1']").animate({top:"150px",left:"0",width:"400px",height:"600px"}, 2000,function(){
? ? ? ? ? ? ? ?$(this).css({"z-index":-100}).attr("data",0)
? ? ? ? ? ?})
? ? ? ? ? ?$("[data='2']").animate({top:"100px",left:"650px",width:"500px",height:"700px"}, 2000,function(){
? ? ? ? ? ? ? ?$(this).css({"z-index":0}).attr("data",1);
? ? ? ? ? ?})
? ? ? ?},2000)
? ?})
</script>
</body>
</html>
在動畫執行完之后再執行css的改變!

TA貢獻10條經驗 獲得超0個贊
看你代碼沒問題啊
你不懂層級關系吧?
那個z-index屬性是設置元素的層級堆疊關系。數字越大的元素總是在數字低的元素前面。
z-index只能在定位元素上有效
添加回答
舉報