简体   繁体   English

如何使输入类型颜色在 2020 年在 IE-11 中工作?

[英]How to make input type color working in IE-11 in 2020?

How to make input type color working in IE in 2020?如何使输入类型颜色在 2020 年在 IE 中工作?

<input type="color">

I tried a lot of polyfills but no luck yet.我尝试了很多 polyfill,但还没有运气。 As a last resort, what external library do you recommend?作为最后的手段,您推荐什么外部库?

For anyone encountering this question, this is the polyfill for IE support:对于遇到此问题的任何人,这是 IE 支持的 polyfill:

https://github.com/jonstipe/color-polyfill

This is a polyfill for implementing the HTML5 <input type="color"> element in browsers that do not currently support it.这是一个 polyfill,用于在当前不支持的浏览器中实现 HTML5 <input type="color">元素。

How to use this:如何使用这个:

Using it is easy — simply include the color-polyfill.js file in the HEAD of the HTML page.使用它很容易——只需在 HTML 页面的HEAD中包含color-polyfill.js文件。 You can then use <input type="color"> elements normally.然后您可以正常使用<input type="color">元素。

If Modernizr detects that the browser doesn't support <input type="color"> , the script will replace these elements with a JavaScript-powered color picker dialog.如果 Modernizr 检测到浏览器不支持<input type="color"> ,脚本将用 JavaScript 驱动的颜色选择器对话框替换这些元素。

A default CSS file is provided.提供了一个默认的 CSS 文件。 You may edit this file to style the buttons and dialog box to make them look the way you want.您可以编辑此文件来设置按钮和对话框的样式,使它们看起来像您想要的那样。

If Modernizr detects support for CSS transitions, you will be able to animate the opening and closing of the dialog box by writing a CSS transition in the CSS file.如果 Modernizr 检测到对 CSS 转换的支持,您将能够通过在 CSS 文件中编写 CSS 转换来为对话框的打开和关闭设置动画。 Otherwise, a jQuery animation is used.否则,将使用 jQuery 动画。

Dependencies: This script requires jQuery, jQuery UI, and Modernizr.依赖项:此脚本需要 jQuery、jQuery UI 和 Modernizr。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM