Home Web Front-end HTML Tutorial Toolbar.js-实用的tooltip样式jQuery工具栏插件_html/css_WEB-ITnose

Toolbar.js-实用的tooltip样式jQuery工具栏插件_html/css_WEB-ITnose

Jun 21, 2016 am 08:59 AM

简要教程

Toolbar.js是一款非常实用的Tooltips样式的jQuery工具栏插件。类似的HTML5中国还分享过一款使用 纯javacript编写的轻量级tooltips工具提示插件html5 tooltipsjs ;Toolbar.js使用非常简单,可以和Font Awesome字体图标配合使用,并且可以制作非常酷的工具栏弹出动画效果。它的特点还有:

  • 使用简单,只需配置少量的参数。
  • 内置了一组可选的工具栏按钮。
  • 工具栏可以附加在任何你需要的元素之上。
  • 工具栏按钮可以通过Font Awesome字体图标来定制。
  • 可以定制工具栏的位置,颜色和动画等。
  • 工具栏是响应式的,会在视口缩放时随按钮的位置而动态改变。
  • 使用CSS3来制作工具栏的动画效果。
  • 兼容IE8+的所有现代浏览器。

查看演示      下载插件

使用方法

使用该jQuery工具栏插件需要在页面中引入jquery和jquery.toolbar.js以及jquery.toolbar.css文件。另外为了使用Font Awesome字体图标还需要引入Font Awesome的相关文件。

<link href="css/jquery.toolbar.css" rel="stylesheet" /><script src="js/jquery.min.js"></script><script src="js/jquery.toolbar.js"></script>
Copy after login

HTML结构

你可以在页面中的任何地方定义工具栏的HTML结构。但是需要记住的是为工具栏添加一个hidden的class类来将其隐藏。

<div id="toolbar-options" class="hidden">   <a href="#"><i class="fa fa-plane"></i></a>   <a href="#"><i class="fa fa-car"></i></a>   <a href="#"><i class="fa fa-bicycle"></i></a></div>
Copy after login

初始化插件

在页面DOM元素加载完毕之后,你可以为任何你需要的DOM元素来附加工具栏,例如:

$('#element').toolbar( options );
Copy after login

配置参数

Toolbar.js插件有以下一些可用的配置参数。

  • content:指向工具栏内容容器的ID号。
$('#button').toolbar({  content: '#toolbar-options',});
Copy after login
  • position:工具栏可以放在元素的上下左右4个位置。通过该参数可以进行位置的设置。
$('#button').toolbar({  content: '#toolbar-options',  position: 'bottom'});
Copy after login
  • style:选择工具栏的样式。它接收和CSS按钮相同的值。
$('#button').toolbar({  content: '#toolbar-options',  position: 'bottom',  style: 'primary'});
Copy after login
  • animation:通过该参数可以设置工具栏的动画效果。共有5中可选的CSS动画效果,具体参看DEMO中的例子。这5种动画的名称分别为:standard, flip, grow, flyin, bounce。
$('#button').toolbar({  content: '#toolbar-options',  position: 'bottom',  style: 'primary',  animation: 'flip'});
Copy after login
  • event:工具栏可以通过鼠标点击或鼠标滑过来触发。
$('#button').toolbar({  content: '#toolbar-options',  position: 'bottom',  style: 'primary',  event: 'click'});
Copy after login
Copy after login
  • hideOnClick:是否在点击页面的任何其它地方时关闭已显示的工具栏。rugged设置为false或不设置,那么需要再次点击按钮才能关闭工具栏。
$('#button').toolbar({  content: '#toolbar-options',  position: 'bottom',  style: 'primary',  event: 'click'});
Copy after login
Copy after login
  • adjustment:用于调整工具栏显示的位置。它接收一个正整数。通常在非标准按钮上使用工具栏时使用该选项来微调工具栏的显示位置。
$('a').toolbar({  content: '#tool-options',  position: 'top',  adjustment: 35});
Copy after login

注意:

触发工具栏的元素在工具栏可见时会被添加一个.pressed的class。

如果需要为图标第一任何JavaScript脚本,需要在调用工具栏之前定义。

高级应用

你可以通过data属性来为多个元素使用同一个工具栏。

<div data-toolbar="user-options"></div>
Copy after login
$('div[data-toolbar="user-options"]').toolbar( options );
Copy after login

你还可以在按钮元素上使用data属性为某个工具栏配置单独的属性。

<div   data-toolbar="user-options"   data-toolbar-event="click"   data-toolbar-style="primary">
Copy after login

事件

你可以通过.on()方法来监听发生在工具栏上的事件。

$('#element').on('toolbarShown',   function( event ) {      // this: the element the toolbar is attached to   });
Copy after login
事件 描述
toolbarShown 在工具栏显示的时候触发
toolbarHidden 在工具栏隐藏的时候触发
toolbarItemClick 在工具栏被点击的时候触发

方法

方法 参数 描述
getToolbarElement None 获取包装每一个工具按钮的元素

来源:jQuery之家

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How do I use HTML5 form validation attributes to validate user input? How do I use HTML5 form validation attributes to validate user input? Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

How to efficiently add stroke effects to PNG images on web pages? How to efficiently add stroke effects to PNG images on web pages? Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

What are the best practices for cross-browser compatibility in HTML5? What are the best practices for cross-browser compatibility in HTML5? Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

How do I use the HTML5 <time> element to represent dates and times semantically? How do I use the HTML5 <time> element to represent dates and times semantically? Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 &lt;time&gt; element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

See all articles