Change text with a CSS3 animation?

前端 未结 2 726
眼角桃花
眼角桃花 2020-12-28 09:43

In my website I want to have a header that fades in and out, then in with different text, then out, then back to normal (looped). Here\'s how I would like it to work:

<
2条回答
  •  [愿得一人]
    2020-12-28 10:25

    Hour ago, been stuck with same question but my decision is this. Just pasted a part of my own code. Check it out, guys!

    body {
    	margin: 0;
    	font-family: sans-serif;
    }
    
    #wrapper {
    	background-color: #051E3E;
    	height: 100vh;
    	color: white;
    	display: flex;
    	justify-content: center;
    	align-items: center;
    }
    
    #hi {
    	animation: pulse 5s;
    }
    
    @keyframes pulse {
    	0% {
    	color: #051E3E;
    	}
    	10% {
    		color: #051E3E;
    	}
    	30% {
    		color: white;
    	}
    	50% {
    		color: #051E3E;
    	}
    	60% {
    		color: #051E3E;
    	}
    	80% {
    		color: white;
    	}
    	100% {
    		color: #051E3E;
    	}
    }
    
    #hi:after {
    	content: "";
    	animation: spin 5s linear;
    }
    
    @keyframes spin {
      0% { content:"Hi"; }
      100% { content:"How do you like it?"; }
    }
    
    
    
    	
    	Document
    	
    
    
    	
    	

提交回复
热议问题