你好,我想做一個可擴展的div當我點擊一個按鈕: 和我想做的步驟動畫,第一步是點擊按鈕,第二個div寬度展開,第3步div高度展開以獲取完整頁面。 和文本里面的div必須改變像隱藏第一個文本,並顯示第二個步驟完成時 任何人都有一個想法如何做到這一點? 還有就是我想要做的步驟的草圖: expand div onClick
1
A
回答
2
$('.blue').click(function(){
//expand red div width to 200px
$('.red').animate({width: "200px"}, 500);
setTimeout(function(){
//after 500 milliseconds expand height to 800px
$('.red').animate({height:"800px"}, 500);
},500);
setTimeout(function(){
//after 1000 milliseconds show textarea (or textbox, span, etc)
$('.red').find('input[type="textarea"]').show();
},1000);
});
2
這可以用CSS真的很容易做到。 This video解釋得非常好。該視頻中有很多其他巧妙的技巧,但我將其與她解釋燈箱的部分聯繫起來。
.container {
padding: 100px;
}
.red,
.blue {
width: 20px;
height: 20px;
float: left;
background-color: blue;
}
.red {
background-color: red;
font-size: 0;
color: white;
width: 50px;
transition: 1s height, 1s margin, 1s font-size, 1s 1s width;
}
.blue:focus ~ .red {
height: 100px;
width: 150px;
font-size: inherit;
margin-top: -40px;
transition: 1s width, 1s 1s height, 1s 1s margin, 1s 1s font-size;
}
.red .hint {
font-size: 14px;
padding: 4px;
transition: 1s 1s font-size;
}
.blue:focus ~ .red .hint {
font-size: 0;
transition: 1s font-size;
}
<div class="container">
<div class="blue" tabindex="-1"></div>
<div class="red"><span class="hint">text1</span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt</div>
</div>
1
$(window).load(function(){
$(".blue").click(function(){
$(".red").animate({width:'400px'},1000).animate({height:'400px',top:'150px'},1000).text("qwqwqwq");
})
})
`的.blue { 寬度:100像素; height:100px; background-color:blue;
}
.red{
width:200px;
height:100px;
background-color: red;
left:100px;
}
div{
display: inline-block;
margin:0;
padding: 0;
position: absolute;
top:300px;
}`
相關問題
- 1. expand height div高度
- 2. Expand div/div divs push div divs down the page
- 3. Jquery Auto expand div div div when sub div height changed
- 4. Slide form on/off page and expand div
- 5. onClick addClass'active'slideDown overlay div,close overlay div onClick next div
- 6. div div onclick
- 7. Onclick div div open exsting
- 8. Div出現onclick,消失onclick
- 9. selenium expand collapse treeview C#
- 10. Onclick refresh only div
- 11. Onclick Change Div Title
- 12. 當onclick去div
- 13. onclick slideToggle + scrollTo DIV
- 14. onclick div not firing
- 15. Autohide div onclick
- 16. Showing div onclick
- 17. 刷新div onClick
- 18. Change div style onclick
- 19. jquery onclick div
- 20. DIV交換onclick
- 21. 翻轉DIV onclick
- 22. Javascript Onclick div類
- 23. Hide div onclick outside
- 24. Olingo貪婪$ expand
- 25. expand collapse JeditorPane
- 26. Android - alert expand
- 27. 擴展dabbrev-expand
- 28. Simple Expand/Collapse divs> JQuery?
- 29. devExtreme TreeView Expand,ScrollTo和Focus
- 30. HTML DIV onclick事件
謝謝你的工作,但問題是,DIV高度會下降只有像高度不要讓之間的平等擴大上下,其僅擴大800像素的底部 – Tiaw
是的,我想你會('。'red')。animate({marginTop:「-350px」,height:「800px」},500);' – stackoverfloweth
是的,謝謝;-) – Tiaw