.cssClip( [dimensions ] )Returns: jQueryversion added: 1.12
Description: Getter/setter for an object version of the CSS clip
property.
-
.cssClip( [dimensions ] )
- dimensionsType: ObjectWhen setting the CSS
clip
property, specify thetop
,right
,bottom
andleft
, properties to use therect()
style.
-
Example:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>cssClip demo</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"> <style> .clipped { position: absolute; width: 150px; height: 150px; background: #3b679e; background: linear-gradient(to bottom, #3b679e 0%, #2b88d9 50%, #207cca 51%, #7db9e8 100%); } </style> <script src="//code.jquery.com/jquery-1.12.4.js"></script> <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script> </head> <body> Click anywhere! <div class="clipped"></div> <script> var clippings = [ { top: 10, right: 50, bottom: 50, left: 5 }, { top: 0, right: 150, bottom: 150, left: 0 } ]; var index = 1; var box = $( ".clipped" ).cssClip( clippings[ 0 ] ); $( document ).click(function() { box.animate( { clip: clippings[ index++ % 2 ] }, 2000 ); }); </script> </body> </html>