2015-04-02 95 views
0

我有兩個文本作爲介紹,其中text1消失和text2保持。問題是,當text1消失時,下面的content div閃爍,並在text2出現時返回到它的位置。任何人都可以解決這個問題嗎?這裏是我的小提琴http://jsfiddle.net/qdrtsvf3/1/Div閃爍淡出

HTML

<div class="text1 animated zoomIn">Welcome to our site</div> 
    <div class="animated text2 bounceIn">Company Name</div> 

<div class="content"> 
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 essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
</div> 

CSS:

body { padding-top:30px;} 
.text2 { 
    display: none; 
} 
.text1,.text2 { 
    font-size:30px; 
    font-weight:bold; 
    text-transform:uppercase; 
    text-align:center; 
} 

.content { background:red} 

JS:

function fade() { 
     $('.text1').fadeIn().delay(2000).fadeOut(); 
     $('.text2').delay(2500).fadeIn(); 
    } 
    fade(); 

回答

2

JSFiddle

我把容器周圍具有固定高度的移動元素。所以當jQuery刪除子元素時,它們下面的文本元素不會受到影響。

<div class="container"> 
<div class="text1 animated zoomIn">Welcome to our site</div> 
<div class="animated text2 bounceIn">Company Name</div> 
</div> 

.container { 
height: 50px; 
} 
1

fadeOut()隱藏text1 div。所以當text2出現時,content div會向上移動500ms。嘗試使用div容器

demo

<div class="container"> 
    <div class="text1 animated zoomIn">Welcome to our site</div> 
<div class="animated text2 bounceIn">Company Name</div> 
</div> 


<div class="content"> 
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 essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
</div> 

body { padding-top:30px;} 
.text2 { 
    display: none; 
} 
.container{ 
    height:50px; 
} 
.text1,.text2 { 
    font-size:30px; 
    font-weight:bold; 
    text-transform:uppercase; 
    text-align:center; 
} 

.content { background:red} 

function fade() { 
     $('.text1').fadeIn().delay(2000).fadeOut(); 
     $('.text2').delay(2500).fadeIn(); 
} 
fade(); 
0

必要組成部分能夠實現與@ Jasper的答案;即

<div class="container"> 
<div class="text1 animated zoomIn">Welcome to our site</div> 
<div class="animated text2 bounceIn">Company Name</div> 
</div> 

.container { 
height: 50px; 
} 

,但問題仍然是出現在動畫水平滾動。爲了避免它使用,

.container { 
    height: 50px; 
    width : 95%; 
} 

Working Demo

+0

好,寬度調整..它是optionary !! – Adhik 2015-04-06 09:14:48