fitty.js 一款字体大小跟随父级容器改变而改变的插件

fitty.js 一款字体大小跟随父级容器改变而改变的插件

父容器变大,那么他也会变大填充

配置参数如下

OptionDefaultDescription
minSize16最小大小 像素
maxSize512最大不超过 像素
multiLinetrue当使用最小字体大小时候是否允许多行显示
observeMutationsMutationObserverInitRescale when element contents is altered. Is set to false when MutationObserver is not supported. Pass a custom MutationObserverInit config to optimize monitoring based on your project. By default contains the MutationObserverInit configuration below or false based on browser support.

第一步引入bfwone

第二步执行插件代码

示例如下

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>BFW NEW PAGE</title>
    <script id="bfwone" data="dep=jquery.17&err=0" type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/bfwone.js"></script>
    <script type="text/javascript">
        bready(function() {
            use(["fitty.min"], function() {
                fitty('#my-element', {
                    minSize: 12,
                    maxSize: 300
                });
            });
        });
    </script>
</head>
<body>

    <div id="my-element">
        Hello World
    </div>

</body>
</html>

官网:https://rikschennink.github.io/fitty/

https://github.com/rikschennink/fitty

立即下载fitty.js查看所有js插件

网友评论0

程序员在线工具箱