Sfoglia il codice sorgente

Listing 4.17: animate() positioning.

Frederic G. MARAND 8 anni fa
parent
commit
82474f3eb5
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      Chapter 4/04.js

+ 3 - 1
Chapter 4/04.js

@@ -38,7 +38,9 @@ $(document).ready(function () {
     var paraWidth = $('div.speech p').outerWidth();
     var $switcher = $(this).parent();
     var switcherWidth = $switcher.outerWidth();
-    $switcher.animate({
+    $switcher.css({
+      position: 'relative'
+    }).animate({
       borderWidth: '5px',
       left: paraWidth - switcherWidth,
       height: '+=20px'