JavaScript + Ajax 実践サンプル集 (1276本以上) ◇編集して実行可能◇
jQueryを使い倒せ! jQueryでAjaxを実装するための基礎知識と実践サンプルを一挙公開中... powered by asp.net 3.5
ホーム
jQuery
jQuery プラグイン
jQuery UI
人気順
カテゴリ
キーワード
クール
新着
ツリー
jQuery PDF
ホット
サイト情報
サイトマップ
★ 新着サンプルトップ50のRSSを購読する
◆ DHTMLサンプル(基礎)のRSSを購読する
◆ DHTMLサンプル(応用)のRSSを購読する
◆ AJAXサンプルのRSSを購読する
◆ その他サンプルのRSSを購読する
◆ BOM(Browser Object Model)のRSSを購読する
◆ DOM(Document Object Model)のRSSを購読する
jQueryのElementStackプラグインでイメージを重ねる
説明
補足説明
コード
分割コード
関連書籍
コメント投稿
このサンプルは、jQueryのElementStackプラグインを利用して複数のイメージを重ねて表示します。サンプルに9個のイメージが表示されたら任意のイメージをクリックしてください。するとクリックしたイメージの背後に他のイメージが重なります。この状態で再度前面のイメージをクリックすると元の位置に戻ります。
このサンプルを編集して試してみる
$('#wrapper').elementStacks({ 'transaction': 'easeOutBack' });
jQuery - ElementStack Plugin
Click on one of the images ...
外部スクリプト
CSS部
HEAD部
BODY部
ボックス内のコードを外部ファイル(*.js)、またはHTMLドキュメントの<HEAD>セクションの<script>タグ内にコピー&ペーストしてください。
/* * jquery.elementStacks. * Stacks elements/images on top of each other with a funky transition. * * Jquery version of http://mootools.net/forge/p/elementstack * by Oskar Krawczyk (http://nouincolor.com). * * Copyright (c) 2010 Marco Fucci * http://www.marcofucci.com * * Requires: jQuery 1.2.3+ * * Licensed under MIT * http://www.opensource.org/licenses/mit-license.php */ (function($) { $.fn.elementStacks = function(options) { var opts = $.extend({}, $.fn.elementStacks.defaults, options); return this.each(function() { var pos, collapsed = false, stackItems = $(opts.itemsSelector, this).css({'z-index': 10}); stackItems .each(function(index, img) { $(img) .attr('coords', this.offsetTop + ':' + this.offsetLeft) .css({'top' : this.offsetTop, 'left' : this.offsetLeft }); }) .css({'position': 'absolute'}) .click(function(e) { var $this = $(this); if (!$this.attr('coords')) { return; }; collapsed = !collapsed; var target = (collapsed) ? $this.css({'z-index': 100}) : null; $this.one('stackfinished', function() { if (!target) { stackItems.css({'z-index': 10}); } }); stackItems.each(function(index, stackItem) { setTimeout(function() { $.fn.elementStacks.reStack.call($this, $(stackItem), collapsed, opts, target, index, index == stackItems.length -1); }, opts.delay * index); }); }); }); }; $.fn.elementStacks.defaults = { 'itemsSelector': 'img', 'rotationDeg': 20, 'delay': 40, 'duration': 900, 'transaction': 'swing' }; $.fn.elementStacks.random = function(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); }; $.fn.elementStacks.reStack = function(stackItem, collapsing, options, target, index, last) { var coords = (target ? target : stackItem).attr('coords').split(':'); var rand = (collapsing ? $.fn.elementStacks.random(-options.rotationDeg, options.rotationDeg) : 0); var $that = this; stackItem.css({ '-webkit-transform': 'rotate(' + rand + 'deg)', '-moz-transform': 'rotate(' + rand + 'deg)' }).animate({ top: parseInt(coords[0]) + rand, left: parseInt(coords[1]) + rand }, options.duration, options.transaction, function() { if (last) { $that.trigger('stackfinished'); } } ); }; })(jQuery);
ボックス内のスタイルシート(CSS)を外部ファイル(*.css)、またはHTMLドキュメントの<HEAD>セクションの<style>タグ内にコピー&ペーストしてください。
body { background-color: #000; font-family: "Georgia" , "Times New Roman" , serif; font-size: .8em; color: #fff; text-align: center; text-shadow: 0 -1px 0 #000; } h1 { font-size: 1.7em; line-height: 150%; } #wrapper { position: relative; height: 320px; width: 280px; margin: 15px auto; } img { position: relative; float: left; padding: 0; margin: 5px; -webkit-box-shadow: 0 0 5px #000; -moz-box-shadow: 0 0 5px #000; border: solid 2px #FFFAF2; border-bottom: solid 15px #FFFAF2; -webkit-transition: -webkit-transform 0.20s ease-in-out; -moz-transition: -moz-transform 0.20s ease-in-out; }
ボックス内のコードをHTMLドキュメントの<HEAD>セクションにコピー&ペーストしてください。
ボックス内のコードをHTMLドキュメントの<BODY>セクションにコピー&ペーストしてください。
Click on one of the images ...
コメント・提案の投稿!
名前
メール
件名
本文
送信中です...
ASP.NET 3.5
|
Akio's Blog