jQuery 使用 jQueryUI 样式化常规表单元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1894618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 12:21:32  来源:igfitidea点击:

Styling regular form elements with jQueryUI

jquerycssjquery-uiformselements

提问by umpirsky

I'm using jQueryUI on my site, as well as http://www.filamentgroup.com/lab/jquery_ui_selectmenu_an_aria_accessible_plugin_for_styling_a_html_select/as replacement for select elements.

我在我的网站上使用 jQueryUI,以及http://www.filamentgroup.com/lab/jquery_ui_selectmenu_an_aria_accessible_plugin_for_styling_a_html_select/作为选择元素的替代品。

But I have a problem to style other form elements, text and textarea.

但是我在设置其他表单元素、文本和文本区域的样式时遇到了问题。

Have anybody idea how to do this right way?

有没有人知道如何正确地做到这一点?

回答by ekhaled

Here is what I use when I want style forms using javascript...

这是我想要使用 javascript 的样式表单时使用的...

http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/

http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/

回答by Steven

Here is my form css. I got this from an online form generator. But I can't find the URL to the site now.

这是我的表单 css。我是从在线表单生成器那里得到的。但是我现在找不到该站点的 URL。

/**** Inputs and Labels ****/

/**** 输入和标签 ****/

label.description
{
    border:none;
    color:#222;
    display:block;
    font-size:95%;
    font-weight:700;
    line-height:150%;
    padding:0 0 1px;
}

span.symbol
{
    font-size:115%;
    line-height:130%;
}

input.text
{
    background:#fff url(../../../images/shadow.gif) repeat-x top;
    border-bottom:1px solid #ddd;
    border-left:1px solid #c3c3c3;
    border-right:1px solid #c3c3c3;
    border-top:1px solid #7c7c7c;
    color:#333;
    font-size:100%;
    margin:0;
    padding:2px 0;
}

input.file
{
    color:#333;
    font-size:100%;
    margin:0;
    padding:2px 0;
}

textarea.textarea
{
    background:#fff url(../../../images/shadow.gif) repeat-x top;
    border-bottom:1px solid #ddd;
    border-left:1px solid #c3c3c3;
    border-right:1px solid #c3c3c3;
    border-top:1px solid #7c7c7c;
    color:#333;
    font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
    font-size:100%;
    margin:0;
    width:99%;
}

select.select
{
    color:#333;
    font-size:100%;
    margin:1px 0;
    padding:1px 0 0;
    background:#fff url(../../../images/shadow.gif) repeat-x top;
    border-bottom:1px solid #ddd;
    border-left:1px solid #c3c3c3;
    border-right:1px solid #c3c3c3;
    border-top:1px solid #7c7c7c;
}


input.currency
{
    text-align:right;
}

input.checkbox
{
    display:block;
    height:13px;
    line-height:1.4em;
    margin:6px 0 0 3px;
    width:13px;
}

input.radio
{
    display:block;
    height:13px;
    line-height:1.4em;
    margin:6px 0 0 3px;
    width:13px;
}


label.choice
{
    color:#444;
    display:block;
    font-size:100%;
    line-height:1.4em;
    margin:-1.55em 0 0 25px;
    padding:4px 0 5px;
    width:90%;
}

Update

更新

And some more CSS

还有一些 CSS

input[type="text"], textarea, input[type="password"] {
  background:#fff url(../img/shadow.gif) repeat-x scroll center top;
  border: solid 1px;
  border-color:#7c7c7c #c3c3c3 #ddd;
  color:#333;
  margin:0;
  padding:2px 0;
}
textarea {
  overflow: auto;
}

input[type="submit"], input[type="button"], input[type="reset"], input[type="file"]
{
  cursor:pointer;
  padding:0 3px 2px 3px; 
  text-align: center;
  vertical-align: bottom;
  height:20px;      
  /*background: transparent url('../img/button_bg1.png') repeat-x;*/
  color: #444;
  font-size: 12px;
    border-top: 1px solid #ccc;
    border-left: 1px solid #ccc;
    border-right: 1px solid #999;
    border-bottom: 1px solid #999;
  border-radius: 5px;             /* CSS3 rounded corners */
  -moz-border-radius: 5px;        /* Rounded corners for Firefox */
  -webkit-border-radius: 5px;     /* Rounded corners for Safari */
  width/*IE*/: auto;
}

input[type="button"] {
  position: relative;
  top: -1px;
}