Explorar o código

Listing 4.17: animate() positioning.

Frederic G. MARAND %!s(int64=8) %!d(string=hai) anos
pai
achega
82474f3eb5
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  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 paraWidth = $('div.speech p').outerWidth();
     var $switcher = $(this).parent();
     var $switcher = $(this).parent();
     var switcherWidth = $switcher.outerWidth();
     var switcherWidth = $switcher.outerWidth();
-    $switcher.animate({
+    $switcher.css({
+      position: 'relative'
+    }).animate({
       borderWidth: '5px',
       borderWidth: '5px',
       left: paraWidth - switcherWidth,
       left: paraWidth - switcherWidth,
       height: '+=20px'
       height: '+=20px'