Home > Web Front-end > JS Tutorial > body text

5 obscure JavaScript libraries that simplify web design

王林
Release: 2023-08-31 16:21:02
Original
995 people have browsed it

In this roundup, we’ll take a look at 5 JavaScript libraries that can truly simplify the development of modern, attractive websites. The libraries we're going to discuss are different from libraries like jQuery or YUI. They are smaller and more specialized. But they do the best in their field and offer unique features.


1. Fix PNG in IE6 using DD_BelatedPNG

  • Creator: Drew Diller
  • License: MIT
  • Purpose: Fix alpha transparent PNG in IE6
  • Size: 6.86kb (after compression)
  • Compatibility: IE6 only
  • View Demo
  • download

DD_belatedPNG was created for the sole purpose of allowing the use of alpha-transparent PNGs in IE6 without resorting to Microsoft's proprietary AlphaImageLoader filter. Anyone who has tried using PNGs in IE6 knows that while they can work to a very basic extent, things like repeating background images are out of the question.

Using the AlphaImageLoader filter only solves half of the PNG problems in IE6 because it only works with background images. In order to be in 5 个简化网页设计的晦涩 JavaScript 库

The library has a method, fix, for providing a simple CSS selector for the library target, anything with a PNG src attribute 5 个简化网页设计的晦涩 JavaScript 库


2.Use any font with Cufon

  • Creator: Simo Kinnunen
  • License: MIT
  • Purpose: Embed non-standard fonts without Flash
  • Size: 17.8kb (compressed)
  • Compatibility: All (all common versions from all common vendors, including IE6)
  • View Demo
  • download

Typography is an area of ​​web development that has seen minimal progress compared to other areas of the industry. Web developers are forced to rely on a small set of "web-safe" fonts that are likely to be installed on the computers of most of their visitors. Image- and flash-based solutions have emerged, both of which have drawbacks to use.

Cufon provides developers with a powerful and fast solution that can be displayed in the browser using the browser's built-in functionality, without the need for third-party plug-ins. Cufon fonts can be used as VML in native IE implementations, or as elements in other more powerful browsers. Amazingly, we can also set different styles for the replacement text, such as color and size, using pure CSS.


usage

This library differs from others in that it requires some preparation before use; a new font file needs to be generated, which can be easily done using the cufon website. An SVG font will be generated and saved in a JS file. This file then needs to be linked to any other



Copy after login

So this is just a case of telling Cufon which elements to replace:


Copy after login

This API provides other solutions for using multiple fonts on the same page and improving IE performance. Even though I refer to this section as "Use Any Font"... you should remember that you should only use fonts that are licensed for embedding. The following screenshot shows the replaced title:

5 个简化网页设计的晦涩 JavaScript 库


3.Use Firebug in any browser

  • Creator: Mike Ratcliff
  • License:BSD Style
  • Purpose: Use all the features of Firebug in browsers other than Firefox
  • Size: 76.9kb (compressed)
  • Compatibility: All non-Firefox browsers
  • View Demo
  • download

Firebug is undoubtedly one of the greatest assets available for web development; of course, I use it every day when doing web development, and I know it's the plugin of choice for many others as well. An unfortunate side effect of Firebug's superior performance is that it pales in comparison to similar tools in other browsers. For example, troubleshooting layout issues and CSS errors in IE can be an exercise in futility.

That's where Firebug Lite comes in; it's a simple JavaScript library that recreates most of the key features of the Firebug interface, bringing our debugger of choice to all other platforms. Fixing layouts and resolving cross-browser issues is easy again.

One of the biggest advantages of Firebug Lite is that you don't have to download or install anything to start using it; when you want to debug the page you're working on in a non-Firefox browser, you just include an SRC script file pointing to the online version. Can:


Copy after login

That's it, Firebug Lite will appear on the page when you run it in any other browser. For offline use, the script file can be downloaded along with the CSS file and should be used like any other JS or CSS file. The following screenshot shows Firebug Lite in Safari:

5 个简化网页设计的晦涩 JavaScript 库


4. 使用 Raphael JS 渲染交互式 3D 形状

  • 创建者:德米特里·巴拉诺夫斯基
  • 许可:麻省理工学院
  • 用途:在页面上绘制 SVG 形状
  • 大小:58.4kb(压缩后)
  • 兼容性:全部(来自所有常见供应商的所有常见版本,包括 IE6)
  • View Demo
  • 下载

好吧,这个库并不是那么小,但这是有原因的;该库可以做很多事情,并向网页添加完整的 SVG 控制。说实话,它的威力是非常强大的。想象一下能够在网页上绘制平滑的曲线并动态创建自定义形状 - 拉斐尔做到了。

您可以制作完全跨浏览器的圆角,没有图像(除了库实际绘制的图像之外),您可以为任何图像创建褪色反射,动态旋转图像等等。由于所有路径都是使用 SVG 元素绘制的,因此您可以将 JavaScript 事件附加到它们,以便人们可以在鼠标悬停或单击(或任何其他 JS 事件)时与图像进行交互。可能性是无限的,API 提供了多种不同的方法,使使用该库成为一种乐趣。


用法

该库当然必须链接到:


Copy after login

该库易于使用,在本示例中我们仅使用了其功能的一小部分。使用此功能的页面应如下所示:

5 个简化网页设计的晦涩 JavaScript 库


5.使用 Modernizr 逐步增强您的网站,迎接未来

5 个简化网页设计的晦涩 JavaScript 库

  • 创建者:Faruk Ateş 和 Paul Irish。
  • 许可:麻省理工学院
  • 用途:检测 HTML5 和 CSS3 支持
  • 大小:7kb(压缩后)
  • 兼容性:全部
  • View Demo
  • 下载

对于 CSS3 和 HTML5 日益进步的 Web 开发来说,这是一个令人兴奋的时刻,但这也是一个令人沮丧的时刻,因为我们在推出所有这些先进的新技术时却很少得到支持。我们希望开始使用所有出色的新 HTML5 和 CSS3 功能,但大多数新 HTML5 元素可能仅在单个浏览器中受支持。

Modernizr 是一个很小的库,它只是测试当前环境是否支持一系列高级功能,例如新的

该库还将类名添加到我们可以使用 CSS 定位的 元素中,以便在页面中隐藏某些元素,因此当支持

这是令人难以置信的,因为这意味着我们可以安全地将这些新功能添加到支持它们的浏览器的页面中,而不会在不支持它们的浏览器中造成混乱。在渐进增强的本质中,我们可以创建一个可访问且广泛支持的内容核心,然后逐步为支持它们的浏览器添加越来越多的功能。


用法

让我们看看它如何显示一些漂亮的 CSS3 效果;首先,我们使用标准

Copy after login

然后我们可以添加以下CSS:

.no-audio #audioContainer { display:none; }
Copy after login

这将确保不支持

Link to the audio
Copy after login

完成此操作后,我们可以检测浏览器是否支持 HTML5 音频并显示或隐藏媒体链接(我们可以仅使用 CSS 轻松完成此操作,但这样我们就可以看到正在运行的 Modernizr 对象):

if (Modernizr.audio) {
  var audioLink = document.getElementById("linkToAudio");
  audioLink.style.display = "none";
}
Copy after login

这就是我们所需要的;有能力的浏览器将看到


结论

这些库中的每一个都解决一个非常具体的问题;它们通常比更知名的通用库小得多,但对于其特殊用途同样有用。它们中的每一个都可以以某种方式帮助我们开发网站,从简化 IE6 中的开发、使用非标准字体而不需要繁琐的替换技术,到检测对最新 CSS3 和 HTML5 技术的支持或生成复杂的交互式图像。

The above is the detailed content of 5 obscure JavaScript libraries that simplify web design. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!