gpt4 book ai didi

jquery - 用动画从下往上展开div

转载 作者:太空宇宙 更新时间:2023-11-04 07:43:59 25 4
gpt4 key购买 nike

我正在尝试从底部到顶部设置按钮高度的动画,并与按钮上方的 div 重叠。

因此: enter image description here

我会得到这样的东西: enter image description here

 <div class="div_1"></div>
<div class="buttons_div">
<button>1</button>
<button>2</button>
<button>3</button>
</dv>
<div class="div_1"></div>

https://jsfiddle.net/o2gxgz9r/21096/

最佳答案

你正在为高度设置动画,这没问题,你也可以使用负值为 margin-top 设置动画以覆盖文本 (只需确保按钮不会位于文本后面通过在必要时添加高 z-index)

$(document).ready(function() {
$('button').on('click', function(){
$(this).animate({'height': '100px','marginTop': '-50px'});
});
});
.div_1{
width: 300px;
height: 150px;
background: blue;
color: #fff;
}
button{
width: 300px;
height: 50px;
border: 0;
display: block;
position:relative;
}
button:nth-of-type(1){
background: yellow;
}
button:nth-of-type(2){
background: green;
}
button:nth-of-type(3){
background: orange;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="div_1">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essenti</div>
<div class="buttons_div">
<button>1</button>
<button>2</button>
<button>3</button>
</div>
<div class="div_1"></div>

关于jquery - 用动画从下往上展开div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48308168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com