【发布时间】:2014-06-04 21:58:43
【问题描述】:
我试图制作淡入/淡出动画。我希望它等待几秒钟,然后基本上在两个 div 之间切换。它可以工作,但它有点跳出它的容器。这是它的样子http://programmingbounty.azurewebsites.net/
这是相关的代码部分:
<div id = "TopBox" style="height: 350px; position: relative;">
<div id = "ForReaders" runat="server" style="opacity: 1" >
<div id = "Welcome" >
Welcome to Programming Bounty, where all your project resources can be easily found and implemented without registration!
<br />
<br />
<ul>
<li>Get high quality code and information from our members</li>
<li>No signup nessesary unless your making a post</li>
<li>Everything is absolutely free!</li>
</ul>
<br />
<a href = "Browse.aspx"> Check it out!</a>
</div>
<div id = "Catagories" align="center">
<h3>What are you searching for?</h3>
<div id = "dropdown">
<asp:DropDownList ID="DropDownList1" runat="server" Width="500px">
<asp:ListItem>Select Language</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
<asp:ListItem>C#</asp:ListItem>
<asp:ListItem>C++</asp:ListItem>
<asp:ListItem>Java</asp:ListItem>
<asp:ListItem>Objective-C</asp:ListItem>
<asp:ListItem>Perl</asp:ListItem>
<asp:ListItem>PHP</asp:ListItem>
<asp:ListItem>Python</asp:ListItem>
<asp:ListItem>Ruby</asp:ListItem>
<asp:ListItem>Visual Basic</asp:ListItem>
<asp:ListItem>HTML/CSS</asp:ListItem>
</asp:DropDownList>
</div>
<br />
<br />
<div id = "getfreecodenow">
<a href = "Library.aspx"> Get Free Code Now!</a>
</div>
</div>
</div>
<div id = "ForWriters" runat="server" style="display: none">
<div id = "WelcomeProgrammers" >
Welcome to Programming Bounty, where you get rewarded for contributions!
<br />
<br />
<ul>
<li>Write short code snippets, tutorials or other resources easily</li>
<li>People see and use your resources</li>
<li>You get paid in either cash or community currency!</li>
</ul>
<br />
<a href = "Library.aspx"> Check it out!</a>
</div>
<div id = "ProgrammingCatagories" align="center">
<h3>What are you searching for?</h3>
<div id = "Div3">
<asp:DropDownList ID="DropDownList3" runat="server" Width="500px">
<asp:ListItem>Select Language</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
<asp:ListItem>C#</asp:ListItem>
<asp:ListItem>C++</asp:ListItem>
<asp:ListItem>Java</asp:ListItem>
<asp:ListItem>Objective-C</asp:ListItem>
<asp:ListItem>Perl</asp:ListItem>
<asp:ListItem>PHP</asp:ListItem>
<asp:ListItem>Python</asp:ListItem>
<asp:ListItem>Ruby</asp:ListItem>
<asp:ListItem>Visual Basic</asp:ListItem>
<asp:ListItem>HTML/CSS</asp:ListItem>
</asp:DropDownList>
</div>
<br />
<br />
<div id = "GetPaidNow">
<a href = "Browse.aspx"> Get Paid Now!</a>
</div>
</div>
</div>
<br />
</div>
</div>
<div id = "TopCodeWrapper">
<div id = "TopCodeContainer">
<div id = "topcodeheader" dir="ltr">
<div id = "Popular">
<h3>Trending Now</h3>
<div id = "tabs" align="left"
style="margin: 0px; ">
<script src="script/jquery.js" type="text/javascript"></script>
<script type = "text/javascript">
function fade() {
var delay = 5000;
$(document.getElementById("<%= ForReaders.ClientID%>")).delay(delay).fadeOut("slow");
$(document.getElementById("<%= ForWriters.ClientID%>")).delay(delay).fadeIn("slow");
$(document.getElementById("<%= ForWriters.ClientID%>")).delay(delay).fadeOut("slow");
$(document.getElementById("<%= ForReaders.ClientID%>")).delay(delay).fadeIn("slow");
}
$(document).ready(function () {
var d = setInterval
(fade(), 1000);
});
</script>
【问题讨论】:
-
原因可能是对所有动画的异步调用。由于动画是异步工作的。所以每个淡入淡出都会并行调用
标签: javascript jquery asp.net css animation