首页 > 解决方案 > 将 github javascript 库 (underline.js) 添加到我的项目中

问题描述

我想在我的文本下划线,因此在我的网页中添加来自 github 的 javascript 库。我知道还有其他选项可以给文本加下划线,但我想使用该库的这个漂亮的下划线。另外,忽略下划线问题,我只想知道如何使用这样的 github 项目。我想添加这个库:https ://github.com/wentin/underlineJS

我之前已经添加了库,但总是提供了一个 npm 安装注释,或者 .jar 文件位于您可以使用的 github 主文件夹中(在 Java 中,而不是 Javascript)

通过查看 github 项目中的代码,我想我至少必须将这个脚本链接添加到我的标题中:

 <link type="text/css" rel="stylesheet" href="css/underline.css" />

然后将其添加到我的 CSS 中:

.underline {
position: relative;
}
.underline span {
 pointer-events: none;

}
.underline canvas {
  pointer-events: auto;
  position: absolute;
  top: 0;
  left: 0;
  /*background-color: rgba(222, 222, 222, 0.1);*/
  /*z-index: -1;*/
  -moz-user-select: none; 
  -khtml-user-select: none; 
  -webkit-user-select: none; 
  -o-user-select: none; 
  cursor: pointer;
}

最后在我的 HTML 中使用它:

<a href="#" class="underline">at your gate</a>
<br>
<br>

但这完全没有效果......

标签: javascript

解决方案


你不能轻易添加这个库,因为它只是一个技术演示。

引用:

尽管名字很吸引人,Underline.js 只是一个技术演示。这意味着如果不先对其进行大量修改,您将无法将其放入任何项目中。

来源:https ://css-tricks.com/styling-underlines-web/#underline-js-canvas


推荐阅读