Saya tidak akan menjelaskannya dengan lebih banyak kata. Biarkan saya memilah langkah -langkah kunci untuk Anda.
Langkah Kunci:
1. Memperkenalkan file JS
<type script = "Text/JavaScript" src = "js/jQuery.min.js"> </script> <script type = "text/javascript" src = 'js/jQuery.thoughtBubble.js'> </script>
2. Di mana efek gelembung diperlukan
<div id = 'mainContainer' class = 'container'> <img src = 'ahout.jpg' id = "thinkBubble" alt = 'whats up?' /> </div>
3. Gunakan efek gelembung
<script type = "text/javascript"> $ (window) .ready (function () {$ ('#thinkBubble'). ThoughtBubble ({text: 'baby, I love you', font: 'avinir'});});4. Ini adalah jQuery.thoughtBubblr.js Code
(function($) {$.fn.thoughtBubble = function( defaults ) {var settings = $.extend({backgroundColor: 'white',fontColor: 'black',width: '330px',height: '210px',fontSize: '15px',bubbleColor: 'white',speed: 125}, defaults ),getBubbleDiv = function( container ) {var offset = container.offset (), dimodifiedHeight = offset.top - parseInt (settings.height), style = '"Posisi: absolute; atas:' + ModifiedHeight + 'px; kiri:' + divset.Left + 'px; lebar:' + settings.width + '; height:'; class = 'bubble-holder' style = " + style +"> " + getMainBubble () + getBubbles () +" </div> "; return bubblecontainer;}, getMainbubble = function () {return '<v> <v>' + getText () + '</Div> </div>"; Tengah; function () {var Bubbles = $ (dokumen) .find ('. Bubble'), Reversed = Bubbles.get (). Reverse (), Speed = Settings.speed; $ (Reversed [0]). Stop (). Animate ({opacity: 1}, speed, function () {$ (reverseded [1]. {$ (terbalik [2]). animate ({opacity: 1}, speed, function () {$ (terbalik [3]). animate ({opacity: 1}, speed, function () {$ (reversed [3]). animate ({opacity: 1}, speed); {});}); Bubbles = $ (dokumen) .find ('. Bubble'); Bubbles.Stop (). Animate ({opacity: 0});}, shiftDiv = function (wadah) {var bubbleHolder = $ (dokumen) .find ('. Bubble-holder'), prorisposisi = container.offset (). Bubble. function () {var $ this = $ (this), container = getBubblediv ($ this); $ this.on ('mouseEnter', animate); $ this.on ('mouseout', unanimate); $ (window) .on ('ubahze', shiftdiv.bind (ini, $ this)); return $ this.on (). prepende) (contape) (continer) (continer) (continer) (continer); return $ this.Bagikan di atas dengan Anda langkah -langkah kunci dari efek gelembung JS. Kode ini sederhana dan mudah dimengerti, jadi saya belum menulis terlalu banyak deskripsi teks. Jika Anda memiliki pertanyaan, silakan tinggalkan saya pesan. Editor akan membalas semua orang tepat waktu. Di sini, saya ingin mengucapkan terima kasih atas dukungan Anda untuk situs web Wulin Network!