开发者 | we_tell |
---|---|
更新时间 | 2012年12月20日 05:16 |
捐献地址: | 去捐款 |
PHP版本: | 3.0.1 及以上 |
WordPress版本: | 3.5 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
css-sprites
folder to the /wp-content/plugins/
directorywp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'image-identifier');
Each sprite is registered as a custom image size. So to access that image you simply need to specify the image identifier you used when registering your sprite; Access image like so eg: 'wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'image-identifier');`
You can use either JavaScript or CSS to animate your sprite. To begin you will need to set the containing block element of your sprite to the width of your sprite and 1/2 of its height. Something like the following; CSS: .css-thumb { width: 200px; height: 150px; overflow: hidden; position: relative; } .css-thumb img { position: absolute; top: 0; left: 0; } Once you have your sprites within a CSS container, you need to animate the sprite, or simply change it's position. The actual positions and dimensions will depend on what you have set within the plugin. Position change with CSS: .css-thumb img:hover { top: -150px; } Animating with Javascript (jQuery): $('#container .css-thumb').on({ mouseenter: function(event) { $('img', this).animate({'margin-top': -($(this).height()) },200); }, mouseleave: function () { $('img', this).animate({'margin-top': '0' }, 500); } });
Yes, as many as you want.