depi
depi

Reputation: 1651

jQuery Cycle plugin

Do you have any idea why jQuery cycle plugin breaks backgorund image centering when sliding images? (without the plugin activated it works okay)

Here is a demo of my page (try to resize the window or zoom out and see what I mean - the background image gets cropped)

Upvotes: 1

Views: 928

Answers (2)

hellslam
hellslam

Reputation: 1550

The cycle plugin sets the width of the divs you are cycling on load, and doesn't account for a resize. Cycle has a destroy method. You should be able to call destroy on cycle and recreate it on a window resize event.

http://jquery.malsup.com/cycle/options.html

$(window).resize(function() {
  $('#home #background').cycle('destroy');
  $('#home #background').cycle({
      random: 1
  }); 
});

Upvotes: 2

Nick Spiers
Nick Spiers

Reputation: 2354

Adding this style fixes it:

#background div { width: 100% !important }

Upvotes: 1

Related Questions