我正在尝试在我正在组装的一个小网站上有一个下拉菜单。由于某种原因,我可以获取我想要向下滑动到 fadeOut() 的 div 并执行其他类似的操作,但我无法将其获取到 SlideDown()。我不知道为什么。上面有文字写着“菜单”。
jQuery 如下。
$(document).ready(function(){
$("#menu").click(function(){
$("#menu").moveDown(40px);
});
});
CSS 在这里
body {
background-color:white;
}
#header {
width:1024px;
height:100px;
margin-top:-25px;
border:2px solid black;
border-radius:20px;
background-color:lightblue;
margin-bottom:10px;
margin-left:auto;
margin-right:auto;
}
#menu {
position:relative;
height:400px;
width:200px;
background-color:blue;
border:2px solid black;
border-radius:15px;
margin-left:850px;
margin-top:-345px;
text-align:center;
}
#menuText {
margin-top:360px;
font-family:Verdana;
font-size:30px;
font-weight:bold;
}
#heading {
font-family:Verdana;
text-align:center;
margin-top:35px;
}
#myCanvas {
background-color:white;
}
canvas {
display:block;
margin:2px;
}
#body {
height:768px;
width:1024px;
margin-left:auto;
margin-right:auto;
border: 2px solid black;
border-radius:20px;
background-color:lightblue;
HTML 在这里。
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="Document2.js"></script>
<link rel="stylesheet" type="text/css" href="Document1.css">
<title>Page Title</title>
</head>
<body>
<div id="menu">
<p id="menuText">Menu</p>
</div>
<div id="header">
<h1 id="heading">Hello There!</h1>
</div>
<div id="body">
<p>This is a line on my website.</p>
<p>This is another line on my website.</p>
<p>I want to make a game like Super Mario.</p>
<p>I alo want to make a Brick Breaker game.</p>
<h3>Below is an unfinished American Flag.</h3>
<p>The dimensions of the flag are exact. All the flag needs is some stars.</p>
<canvas id="myCanvas" width="190" height="100" style="border:2px solid black"> </canvas>
<canvas id="circle" width="500" height="250" style="border:2px solid black"> </canvas>
<p id="date"> </p>
</div>
<script src="Document1.js"></script>
</body>
</html>
我确实有另一个 Javascript 文档,但它仅用于在画布上绘制一些图片。我是一个业余爱好者,所以如果答案措辞简单的话会有帮助。非常感谢您花时间阅读本文,如果有人可以帮助像我这样的新手,我将非常感激。
slideDown() only works on the elements which is hidden with jQuery methods or css display:none.
在你的问题中,你的 div 已经达到了顶峰。
所以你必须设置另一个 div 来包含你的菜单并将其显示设置为无;
然后单击menu
你可以把它滑下来。
我已经树立了榜样Fiddle http://jsfiddle.net/aPgwV/2/
Update Fiddle http://jsfiddle.net/aPgwV/5/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)