File tree Expand file tree Collapse file tree 3 files changed +36
-5
lines changed
projects/testimonial-slider Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Original file line number Diff line number Diff line change 99 </ head >
1010 < body >
1111 < div class ="testimonial-container ">
12+ < button class ="arrow prev " onclick ="prevTestimonial() "> ❮</ button >
1213 < img
1314 src ="https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=880&q=80 "
1415 alt ="user-image "
1819 best. Not able to tell you how happy I am with Apple.
1920 </ p >
2021 < h4 class ="username "> Cherise G</ h4 >
22+ < button class ="arrow next " onclick ="nextTestimonial() "> ❯</ button >
2123 </ div >
2224 < script src ="index.js "> </ script >
2325 </ body >
Original file line number Diff line number Diff line change @@ -32,11 +32,20 @@ function updateTestimonial() {
3232 imgEl . src = photoUrl ;
3333 textEl . innerText = text ;
3434 usernameEl . innerText = name ;
35+ }
36+
37+ function nextTestimonial ( ) {
3538 idx ++ ;
36- if ( idx == = testimonials . length ) {
39+ if ( idx > = testimonials . length ) {
3740 idx = 0 ;
3841 }
39- setTimeout ( ( ) => {
40- updateTestimonial ( ) ;
41- } , 10000 ) ;
42+ updateTestimonial ( ) ;
43+ }
44+
45+ function prevTestimonial ( ) {
46+ idx -- ;
47+ if ( idx < 0 ) {
48+ idx = testimonials . length - 1 ;
49+ }
50+ updateTestimonial ( ) ;
4251}
Original file line number Diff line number Diff line change 88}
99
1010.testimonial-container {
11+ position : relative;
1112 width : 500px ;
1213 height : 100px ;
1314 background-color : slateblue;
1718 padding : 70px 20px ;
1819 margin : 5px ;
1920 color : white;
20- position : relative;
2121}
2222
2323img {
3434 font-size : 13px ;
3535 font-weight : 100 ;
3636}
37+
38+ .arrow {
39+ position : absolute;
40+ top : 50% ;
41+ transform : translateY (-50% );
42+ background : none;
43+ border : none;
44+ color : white;
45+ font-size : 24px ;
46+ cursor : pointer;
47+ margin : 70px ;
48+ }
49+
50+ .arrow .prev {
51+ left : 10px ;
52+ }
53+
54+ .arrow .next {
55+ right : 10px ;
56+ }
You can’t perform that action at this time.
0 commit comments