基于jQuery實現Taggd圖像標簽提示特效



47 184 62



特效描述:基于jQuery實現 Taggd 圖像標簽提示,基于jQuery實現Taggd圖像標簽提示特效

代碼結構

1. 引入CSS

<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/taggd.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />

2. 引入JS

<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery.taggd.js"></script>

3. HTML代碼

<div id="container">
    <div id="example">
        <img class="taggd" src="img/example.jpg" alt="photo" />
        <script type="text/javascript">
            data.push([
                { x: 0.512, y: 0.33, text: 'Huey' },
                { x: 0.548, y: 0.33, text: 'Dewey' },
                { x: 0.567, y: 0.36, text: 'Louie' }
            ]);
            settings.push({
                align: { 'y': 'bottom' },
                offset: { 'top': -15 },
                'handlers': {
                    'mouseenter': 'show',
                    'mouseleave': 'hide'
                }
            });
        </script>
    </div>
    <div class="content-wrapper">
	<img src="img/taggd.png" class="logo" alt="taggd" />
    <p>
        <strong>“A picture is worth a thousand words”</strong>, but sometimes 
		even a thousand words are just not enough.<br />
        <strong>Taggd</strong> is a jQuery plugin that help you create tags on images with, or without a 
		popup!
    </p>
    <ol>
        <li>
            <a href="#begin">Getting started</a>
            <ol>
                <li><a href="#download">Download</a></li>
                <li><a href="#basic-usage">Basic usage</a></li>
                <li><a href="#custom">Customization</a></li>
            </ol>
        </li>
        <li>
            Documentation
            <ol>
                <li>
                    <a href="#configuration">Configuration</a>
                    <ol>
                        <li><a href="#align">Align Object</a></li>
                        <li><a href="#handler">Handler Object</a></li>
                        <li><a href="#offset">Offset Object</a></li>
                    </ol>
                </li>
                <li>
                    <a href="#items">Items</a>
                    <ol>
                        <li><a href="#item">Item Object</a></li>
                    </ol>
                </li>
            </ol>
        </li>
        <li>
            Demo&#39;s
            <ol>
                <li><a href="#demo-0">Hover top popup</a></li>
                <li><a href="#demo-1">Click bottom popup</a></li>
                <li><a href="#demo-2">Click-mouseout left popup</a></li>
                <li><a href="#demo-3">Click custom</a></li>
            </ol>
        </li>
    </ol>
</div>
    <div id="begin">
        <div class="content-wrapper">
    <h2>Getting started</h2>
    <p>But, without data, there are no tags! We have to write just one more 
	line:</p>
    <pre>$( image ).taggd( &#39;items&#39;, data );</pre>
    <p>Read <a href="#items">Items</a> to learn how to set up the data.</p>
    <h3 id="custom">Customization</h3>
    <p>Of course, sometimes you want to do more than just a popup. By discarding 
	the <code>text</code> property of the <a href="#items">items</a>, and using 
	a function as <a href="#handler">Handler</a>, you can do whatever you want, 
	just like <a href="#demo-3">this demo</a>. If you need item-specific data in 
	the Handler, you can just add more properties to the <a href="#item">Item 
	Object</a>.</p>
    <p>CSS styles are easily customizable. Just edit or replace the CSS rules in 
	the file <code>css/taggd.css</code>.</p>
</div>
    </div>
    <div class="content-wrapper">
    <h2 id="configuration">Configuration</h2>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Value</td>
            <td>Description</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>align</td>
            <td><a href="#align">Align Object</a></td>
            <td>Popup aligning settings</td>
        </tr>
        <tr>
            <td>handlers</td>
            <td><a href="#handler">Handler Object</a></td>
            <td>Event handlers</td>
        </tr>
        <tr>
            <td>offset</td>
            <td><a href="#offset">Offset Object</a></td>
            <td>Offset of the hover element in pixels</td>
        </tr>
        </tbody>
    </table>
</div>
<div class="content-wrapper">
    <h3 id="align">Align Object</h3>
    <p>Aligning is two-dimensional; the X-axis and the Y-axis. When you align an 
	object <strong>left</strong>, the <strong>left side</strong> is snapped 
	against the button.</p>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Value</td>
            <td>Default</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>x</td>
            <td><code>String</code> left, right or center</td>
            <td>center</td>
        </tr>
        <tr>
            <td>y</td>
            <td><code>String</code> top, bottom or center</td>
            <td>center</td>
        </tr>
        </tbody>
    </table>
    <h4>Example</h4>
    <pre>{
    x: 13,
    y: 37
}</pre>
</div>
<div class="content-wrapper">
    <h3 id="handler">Handler Object</h3>
    <p>Handlers are used to add actions to the buttons. These are JavaScript 
	events like <code>click</code>, <code>mouseenter</code>, etc.<br />The 
	handler can be a function, or a string for popup interaction.</p>
    <table>
        <thead>
        <tr>
            <td>String</td>
            <td>Description</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>show</td>
            <td>Shows the popup</td>
        </tr>
        <tr>
            <td>hide</td>
            <td>Hides the popup</td>
        </tr>
        <tr>
            <td>toggle</td>
            <td>Toggles the popup visability</td>
        </tr>
        </tbody>
    </table>
    <h4>Example</h4>
    <pre>{
    click: function() {
        alert(&#39;You clicked the tag!&#39;);
    },
    mouseenter: &#39;show&#39;,
    mouseleave: &#39;hide&#39;
}</pre>
</div>
<div class="content-wrapper">
    <h3 id="offset">Offset Object</h3>
    <p>The offset is the offset of the popup in pixels.</p>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Value</td>
            <td>Default</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>left</td>
            <td><code>Number</code></td>
            <td>0</td>
        </tr>
        <tr>
            <td>top</td>
            <td><code>Number</code></td>
            <td>0</td>
        </tr>
        </tbody>
    </table>
    <h4>Example</h4>
    <pre>{
    left: 13,
    top: 37
}</pre>
</div>
<div class="content-wrapper">
    <h2 id="items">Items</h2>
    <p>Items are what drives taggd. Without items, there&#39;s no way it would know 
	where to put the tags and popups. That&#39;s why, we need items.</p>
    <p>Items can be set with the following line, where <code>data</code> is an 
	array of <a href="#item">Item Objects</a>.</p>
    <pre>$( image ).taggd( &#39;items&#39;, data );</pre>
</div>
<div class="content-wrapper">
    <h3 id="item">Item Object</h3>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Description</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td><code>Float</code> x</td>
            <td>X position of the tag (and popup)</td>
        </tr>
        <tr>
            <td><code>Float</code> y</td>
            <td>Y position of the tag (and popup)</td>
        </tr>
        <tr>
            <td><code>String</code> text</td>
            <td>Optional. Set&#39;s the text of the popup. If omitted, there will be 
			no popup.</td>
        </tr>
        </tbody>
    </table>
    <p>The <code>x</code> and <code>y</code> property can be in a scale from 0 
	to 1, or a number in pixels based on the image&#39;s dimensions. Both are 
	scalable.</p>
    <p>This object also accepts custom properties, that can be read using a <a href="#handler">
	Handler</a>.</p>
    <h4>Example</h4>
    <pre>{
    x: 0.5,
    y: 0.5,
    text: &#39;Popup text&#39;
}</pre>
</div>
    <div id="demo-0">
    <img class="taggd" src="img/demo-0.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
                <pre>{
    align: {
        y: &#39;bottom&#39;
    },
    offset: {
        top: -15
    },
    handlers: {
        mouseenter: &#39;show&#39;,
        mouseleave: &#39;hide&#39;
    }
}</pre>
        <h3>Items</h3>
                <pre>[
    { x: 1099,  y: 220,  text: &#39;Dave&#39;   }, // pixel-based
    { x: 0.431, y: 0.33, text: &#39;Phil&#39;   }, // scale (0 - 1)
    { x: 0.468, y: 0.28, text: &#39;Steven&#39; }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.572, y: 0.343, text: 'Dave' },
            { x: 0.431, y: 0.33, text: 'Phil' },
            { x: 0.468, y: 0.28, text: 'Steven' }
        ]);
        settings.push({
            align: { 'y': 'bottom' },
            offset: { 'top': -15 },
            'handlers': {
                'mouseenter': 'show',
                'mouseleave': 'hide'
            }
        });
    </script>
</div>
<div id="demo-1">
    <img class="taggd" src="img/demo-1.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
            <pre>{
    align: {
        y: &#39;top&#39;
    },
    offset: {
        top: 15
    },
    handlers: {
        click: &#39;toggle&#39;
    }
}</pre>
        <h3>Items</h3>
            <pre>[
    { x: 0.62, y: 0.7, text: &#39;Rope&#39;             },
    { x: 0.51, y: 0.5, text: &#39;Bird&#39;             },
    { x: 0.40, y: 0.3, text: &#39;Water, obviously&#39; }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.62, y: 0.7, text: 'Rope' },
            { x: 0.51, y: 0.5, text: 'Bird' },
            { x: 0.40, y: 0.3, text: 'Water, obviously' }
        ]);
        settings.push({
            align: { 'y': 'top' },
            offset: { 'top': 15 },
            'handlers': {
                'click': 'toggle'
            }
        });
    </script>
</div>
<div id="demo-2">
    <img class="taggd" src="img/demo-2.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
            <pre>{
    align: {
        x: &#39;right&#39;
    },
    offset: {
        left: -15
    },
    handlers: {
        click: &#39;show&#39;,
        mouseleave: &#39;hide&#39;
    }
}</pre>
        <h3>Items</h3>
            <pre>[
    { x: 0.415, y: 0.343, text: &#39;Leaf&#39;                   },
    { x: 0.25,  y: 0.33,  text: &#39;More water&#39;             },
    { x: 0.8,   y: 0.1,   text: &#39;This used to be a tree&#39; }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.415, y: 0.343, text: 'Leaf' },
            { x: 0.25, y: 0.33, text: 'More water' },
            { x: 0.8, y: 0.1, text: 'This used to be a tree' }
        ]);
        settings.push({
            align: { 'x': 'right' },
            offset: { 'left': -15 },
            'handlers': {
                'click': 'show',
                'mouseleave': 'hide'
            }
        });
    </script>
</div>
<div id="demo-3">
    <img class="taggd" src="img/demo-3.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
            <pre>{
    align: {
        y: &#39;bottom&#39;
    },
    offset: {
        top: -12
    },
    handlers: {
        click: function( e ) {
            var wiki = &#39;http://en.wikipedia.org/wiki/&#39; + e.data.uri;
            window.open( wiki, &#39;_blank&#39; );
        },
        mouseenter: &#39;show&#39;,
        mouseleave: &#39;hide&#39;
    }
}</pre>
        <h3>Items</h3>
            <pre>[
    { x: 0.1,  y: 0.54, text: &#39;Auto Rickshaw&#39;,      uri: &#39;Auto_rickshaw&#39;              },
    { x: 0.49, y: 0.57, text: &#39;Registration Plate&#39;, uri: &#39;Vehicle_registration_plate&#39; },
    { x: 0.38, y: 0.9,  text: &#39;Lighting&#39;,           uri: &#39;Automotive_lighting&#39;        }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.1, y: 0.54, text: 'Auto Rickshaw', uri: 'Auto_rickshaw' },
            { x: 0.49, y: 0.57, text: 'Registration Plate', uri: 'Vehicle_registration_plate' },
            { x: 0.38, y: 0.9, text: 'Lighting', uri: 'Automotive_lighting' }
        ]);
        settings.push({
            'align': { 'y': 'bottom' },
            'offset': { 'top': -12 },
            'handlers': {
                'click': function(e) {
                    var wiki = 'http://en.wikipedia.org/wiki/' + e.data.uri;
                    window.open(wiki, '_blank');
                },
                mouseenter: 'show',
                mouseleave: 'hide'
            }
        });
    </script>
</div>
</div>
<div style="text-align:center;clear:both">
</div>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: 文字疊加 文字層疊 文字淡出淡進 文字淡出 文字淡進 文字翻轉 文字旋轉 文字放大縮小 文字縮放 文字大小 文字放大 文字縮小 文字變大 文字變小 文字收縮展開 文字收縮 文字展開 文字提示框 提示文字 文字全屏 文字拖動 文字拖拽 文字延遲加載 文字延遲 文字加載 h5文字動畫 h5文字邊框動畫 html5文字動畫 html5文字邊框動畫 360全景 360度全景 文字滑動 文字滑塊 文字滾動 文字無縫滾動 文字間歇滾動 彈出層拖動 文字切換 文字選項卡 全屏焦點圖 窗口 彈出 彈窗 彈出層 提示框 對話框 遮罩 遮罩層 彈窗插件 滑動星星打分 圖片文字 文字導航菜單 文字導航 文字菜單 全屏切換 寬屏全屏 寬屏 全屏 頁面全屏 頁面寬屏 文字 文字插件 其他 圖片全屏 文字標簽 文字標簽云 標簽云 文字提示框 提示文字 鼠標滑過 鼠標懸停 跟隨鼠標移動
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

湖北30选5开奖结果走势图表