如何切换(或缩放)以减小 DIV 的垂直尺寸(但仅减小到初始高度的 30%)
所以我有一个横跨页面宽度的 DIV(地图),但我希望有一个用户可以单击“隐藏/取消隐藏”DIV 的按钮,单击该按钮基本上会执行三件事:
- 缩放div 的垂直高度为原始高度的 25%...
- 将 DIV 更改为不透明度 0.3,以便在高度减小时它会褪色...
- 恢复到正常高度和高度再次单击时不透明度 (1)
以下是我到目前为止所得到的: 目前它只能缩小到正确的垂直高度
非常感谢您的帮助...
<!-- JQUERY STUFF ADDED IN THE HEAD-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<!-- THE CODE -->
<div id="map">
Map Content Is Here
</div>
<p class="hidemap">HIDE MAP</p>
<script>
$(document).ready(function() {
$("p.hidemap").click(function () {
$("#map").effect("scale", { percent: 25, direction: 'vertical' }, 500);
});
});
</script>
So I've got a DIV (a map) that goes across the width of the page, but i'd like to have a button users can click to "Hide/Unhide" the DIV that will basically do three things when clicked:
- scale the vertical height of the div to 25% of the original height...
- Change the DIV to have opacity .3 so its faded when at its reduced height...
- Revert back to normal height & opacity (1) when clicked again
Here's what I've got so far: Currently it only scales down to the correct vertical height
Really appreciate the help...
<!-- JQUERY STUFF ADDED IN THE HEAD-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<!-- THE CODE -->
<div id="map">
Map Content Is Here
</div>
<p class="hidemap">HIDE MAP</p>
<script>
$(document).ready(function() {
$("p.hidemap").click(function () {
$("#map").effect("scale", { percent: 25, direction: 'vertical' }, 500);
});
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这样的事情:
工作示例: http://jsfiddle.net/X4NaV/
Try something like this:
Working example: http://jsfiddle.net/X4NaV/
基于外星人的,这里有:
脚本:
希望这有帮助。干杯
Based on Alien's, here you have:
The script:
Hope this helps. Cheers