简体   繁体   English

如何使用JavaScript和CSS轻松地为表单元素设置样式?

[英]How to style form elements unobtrusively with JavaScript and CSS?

如何在包括IE6在内的所有浏览器中毫不费力地为元素设置样式

There are a few plugins that do what you want. 有一些插件可以满足您的需求。 Basically, you want to add special styling to forms via javascript + css, but want the form to function normally if javascript is disabled 基本上,您想通过javascript + css向表单添加特殊样式,但是如果禁用了javascript,则希望表单正常运行

Here are two such plugins, but I am sure there are more out there: 这里有两个这样的插件,但是我敢肯定还有更多的插件:

  1. Uniform for jQuery on Github and The Overview GitHub概述 上的jQuery制服
  2. FancyForm for MooTools MooTools的FancyForm

This new plugin works pretty well and is more robust than uniforms. 这个新插件效果很好,并且比制服更强大。 http://customformsjs.com/ http://customformsjs.com/

为您的元素使用类名称 ,这些元素通常无法在CSS中应用样式。

So far i found this is best and works in IE 6+, safari 2+, firefox 2+ 到目前为止,我发现这是最好的,并且可以在IE 6 +,safari 2 +,firefox 2+中使用

http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/ http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/ 替代文字
(source: blogfreakz.com ) (来源: blogfreakz.com

Use jQuery . 使用jQuery Specifically the toggleClass function and then use CSS classes to style your forms. 特别是toggleClass函数,然后使用CSS类来设置表单样式。 No plugin required. 无需插件。 See jQuery Attributes Documentation . 请参阅jQuery属性文档

If you want more styles, check out jQuery UI . 如果您想要更多样式,请查看jQuery UI

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

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