Bu yazadıda jquery ile kayan yazı nasıl yapılır sorusuna cevap bulacağız. <marquee> etiketinin kullanımı HTML5 ile kaldırıldı. Artık <marquee> etiketi yerine javascript / jquery kullanarak kayan yazı uygulamaları yapıyoruz. Aşağıdaki bir kaç jquery kayan yazı örneği ile sayfalarınıza marquee etiketindeki etkiyi verebilirsiniz.
Jquery marquee yapımı:DEMO
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <html> <head> <title>Marquee</title> <!--meta--> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!--fonts--> <link href='https://fonts.googleapis.com/css?family=Telex' rel='stylesheet' type='text/css'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></ </script> <script type='text/javascript' src='//cdn.jsdelivr.net/jquery.marquee/1.4.0/jquery.marquee.min.js'></script> <style> .marquee { margin-top:200px; width: 600px; overflow: hidden; background: black; color:white; font-size:2em; padding:5px; } </style> </head> <body> <div class="marquee">Tasarım Kodlama</div> <script> $('.marquee').marquee({ //speed in milliseconds of the marquee duration: 5000, //gap in pixels between the tickers gap: 50, //time in milliseconds before the marquee will start animating delayBeforeStart: 0, //'left' or 'right' direction: 'left', //true or false - should the marquee be duplicated to show an effect of continues flow duplicated: false }); </script> </body> </html> |
JavaScript Marquee Örneği: DEMO
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <html> <head> <title>Marquee</title> <!--meta--> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!--fonts--> <link href='https://fonts.googleapis.com/css?family=Telex' rel='stylesheet' type='text/css'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <style> .marquee { display: inline-block; white-space: nowrap; /* animation: scrollLeft 38s linear infinite; */ padding-left: 101%; } .marquee:hover { animation-play-state: paused } @keyframes scrollLeft { 0% { transform: translateX(0%); } 100% { transform: translateX(-100%) } } </style> </head> <body> <div class="marquee">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> <script> var marquee = document.querySelector('.marquee'); var marqueeLength = marquee.clientWidth; var marqueeTravelTime = Math.ceil( marqueeLength / 100 ); marquee.style.animation = `scrollLeft ${marqueeTravelTime}s linear infinite`; marquee.addEventListener('mouseover', (e)=>{ marquee.style['animation-play-state'] = 'paused'; }) marquee.addEventListener('mouseout', (e)=>{ marquee.style['animation-play-state'] = 'running'; }) </script> </body> </html> |
Jquery marquee örneği : DEMO
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | <html> <head> <title>Marquee</title> <!--meta--> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!--fonts--> <link href='https://fonts.googleapis.com/css?family=Telex' rel='stylesheet' type='text/css'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <style> @charset "UTF-8"; body, html, div.marquee, div.fade-left, div.fade-right, span.marquee-message { margin: 0; padding: 0; } div.marquee, div.marquee2 { width: 100%; background: #222222; position: relative; overflow: hidden; height: 40px; -moz-box-shadow: 1px 1px 1px #434343; -webkit-box-shadow: 1px 1px 1px #434343; box-shadow: 1px 1px 1px #434343; } span.marquee-message { color: #ffffff; font-family: 'Telex'; white-space: nowrap; margin: 10px 0 0 0; display: inline-block; } div.fade-left { background: -moz-linear-gradient( left, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: -webkit-gradient( linear, left top, right top, color-stop(12%,rgba(0,0,0,1)), color-stop(100%,rgba(0,0,0,0)) ); background: -webkit-linear-gradient( left, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: -o-linear-gradient( left, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: -ms-linear-gradient( left, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: linear-gradient( to right, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); position: absolute; left: 0; height: 40px; width: 10%; } div.fade-right { background: -moz-linear-gradient( right, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: -webkit-gradient( linear, right top, right top, color-stop(12%,rgba(0,0,0,1)), color-stop(100%,rgba(0,0,0,0)) ); background: -webkit-linear-gradient( right, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: -o-linear-gradient( right, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: -ms-linear-gradient( right, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); background: linear-gradient( to left, rgba(0,0,0,1) 12%, rgba(0,0,0,0) 100% ); position: absolute; right: 0; height: 40px; width: 10%; } </style> </head> <body> <div class="marquee"> <div class="fade-left"></div> <div class="fade-right"></div> <span class="marquee-message">Merhaba Dünya</span> </div> <br /> <div class="marquee2"> <div class="fade-left"></div> <div class="fade-right"></div> <span class="marquee-message">Tasarım Kodlama</span> </div> <script> $( document ).ready( function () { function marquee ( bar, speed, direction ) { //main marquee function //marquee text width var initWidth = $( bar + " .marquee-message" ).width(); //initial position $( bar + " .marquee-message" ).css( 'margin-left', function () { return ( $( bar ).width() - initWidth ) / 2; } ); if ( direction == 'left' ) { //from left to right //resetting the marquee element function resMarquee_left () { var left = -1 * initWidth; $( bar + " .marquee-message" ).css( 'margin-left', left ); } //marquee function function marquee_left () { $( bar + " .marquee-message" ).css( 'margin-left', function ( index, val ) { return parseInt( val, 10 ) + speed + 'px'; } ); //reset the element if it's out of it's container if ( parseInt ( $( bar + " .marquee-message" ).css( 'margin-left' ) ) > $( bar ).width() ) { resMarquee_left (); } } setInterval( marquee_left, 10 ); } else { //default: from right to left //marquee text width var initWidth = $( bar + " .marquee-message" ).width(); //initial position $( bar + " .marquee-message" ).css( 'margin-left', function () { return ( $( bar ).width() - initWidth ) / 2; } ); //resetting the marquee element function resMarquee_right () { $( bar + " .marquee-message" ).css( 'margin-left', $( bar ).width() ); } //marquee function function marquee_right () { $( bar + " .marquee-message" ).css( 'margin-left', function ( index, val ) { return parseInt( val, 10 ) - speed + 'px'; } ); //reset the element if it's out of it's container if ( parseInt ( $( bar + " .marquee-message" ).css( 'margin-left' ) ) < -1 * $( bar + " .marquee-message" ).width() ) { resMarquee_right (); } } setInterval( marquee_right, 10 ); } } marquee( ".marquee", 1, 'left' ); marquee( ".marquee2", 3, 'right' ); } ); </script> </body> </html> |
Merhaba, hocam elinize sağlık valla aradığımı buldum sayenizde teşekkürler 🙂