最近开发项目,想增长滑动提示文字,相似img alt和i的title,可是效果都不是很理想,固然jq也有,可是用起来比较繁琐,使用不是特别方便css
因而在github上看到了一个不错的库:css3
https://github.com/sevck/microtipgit
国外写的一个纯css3的tooltipsgithub
安装使用很简单:shell
via npmnpm
npm install microtip
via yarnapp
yarn add microtip
via CDNcurl
https://unpkg.com/microtip/microtip.css
direct download字体
curl -o microtip https://github.com/ghosh/microtip/blob/master/microtip.css
in PostCSSurl
@import 'microtip';
in Webpack
import microtip from 'microtip/microtip.css'
in SCSS
@import 'microtip/microtip';
<link rel="stylesheet" type="text/css" href="css/microtip.css">
<button aria-label="Hey tooltip!" data-microtip-position="up" role="tooltip">
也支持调整显示的位置,滑动出现的时间、字体大小等等
Microtip uses css variables, which allows you to customize the behavior of the tooltip as per your needs.
Variable | Description | Default Value |
---|---|---|
--microtip-transition-duration |
Specifies the duration of the tootltip transition | .18s |
--microtip-transition-delay |
The delay on hover before showing the tooltip | 0s |
--microtip-transition-easing |
The easing applied while transitioning the tooltip | ease-in-out |
--microtip-font-size |
Sets the font size of the text in tooltip | 13px |
--microtip-font-weight |
The font weight of the text in tooltip | normal |
--microtip-text-transform |
Controls the casing of the text | none |
效果:
鼠标移动文字提示,或者重写覆盖样式都是能够的