Skip to content

Commit 794d996

Browse files
committed
Add transition
1 parent 3fffa63 commit 794d996

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Week1/project/index.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ font-size: 2.2rem;
3434
margin: 40px 40px;
3535
position: relative;
3636
text-align: center;
37-
animation: slide 0.5s ease-out;
37+
left: -1000px;
3838
}
3939

40-
@keyframes slide {
41-
0% {margin-left: -600px;}
42-
100%{margin-left: 40px;}
40+
.transition{
41+
transform: translate(1000px);
42+
transition: transform 1000ms;
4343
}
4444

4545

Week1/project/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<body>
1616
<div class="container">
1717
<div class="quote">
18-
<blockquote id="quote">Wisely, and slow. They stumble that run fast</blockquote>
18+
<blockquote class="transition" id="quote">Wisely, and slow. They stumble that run fast</blockquote>
1919
<h2 id="author">William Shakespeare</h2>
2020
<div class="clearFix"></div>
2121
</div>

Week1/project/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ let quoteNum = 0;
5050
button.addEventListener('click', changeQuote);
5151

5252
function changeQuote() {
53+
quote.classList.remove('transition');
54+
setTimeout(() => {
55+
quote.classList.add('transition');
56+
}, 5)
5357
quote.textContent = quotes[quoteNum].quote;
5458
author.textContent = quotes[quoteNum].author;
5559
quoteNum++;

0 commit comments

Comments
 (0)