简体   繁体   English

自定义表单元素样式

[英]Custom Form Elements Styling

I want to make some custom form elements. 我要制作一些自定义表单元素。 Which is the best library to use to make custom form elements ? 哪个是用来制作自定义表单元素的最佳库?

Mainly i am looking at File upload and Select Box. 主要是我在看文件上传和选择框。

The rest of the set i can style it in CSS3. 其余的我可以在CSS3中设置样式。

选择文件元素

Harsha bhai try making your own design, it will be a good learning experience, because it is easy Harsha bhai尝试制作自己的设计,这将是一个很好的学习经历,因为它很容易

You just have to understand few tricks (like for the choose-file element that you see), these tricks just involve overlaying the non-stylable elements with divs that you create. 您只需要了解一些技巧(例如您看到的select-file元素),这些技巧仅涉及将非样式元素与您创建的div叠加。

Use jquery/css for quikly learning how to position these divs on top of non-stylable elements, once this is done it will be fairly same across all browsers, but there is a slight difference like for the choose file element. 使用jquery / css快速学习如何将这些div放置在非样式元素的顶部,一旦完成,在所有浏览器中都将完全相同,但是与select file元素略有不同。 I have given the necessary html,jquery that I use, if you have any doubt you can ask another question. 我已经提供了必要的html,jquery,如果您有任何疑问,可以提出另一个问题。

 $(function(){
  $('div#input_file_outer input[type=file]').change(function(e){
    $('div.file_name').html($('div#input_file_outer input[type=file]').val()); });
    $('div#input_file_outer input[type=file]').css({'cursor':'pointer'});

    if($.browser.opera) {
      $('div.file_name').css({'float':'left'});
      $('span.input_file_label').css({'float':'right','cursor':'pointer'});
    }
    if(!$.browser.opera) {
      $('span.input_file_label').css({'left':'-4px'});
    }
    $("div.input_file_cover,div#input_file_outer").css( { 'width':$("input.upload_file").outerWidth()+9+'px', 'height':$("input.upload_file").outerHeight()+2+'px', 'cursor':'pointer' });
    $("div.file_name,span.input_file_label").css( { 'height':$("input.upload_file").outerHeight()+'px', 'cursor':'pointer' });
  });

<input type="file" name="photograph" class="upload_file" title="Upload your jpeg/jpg photographs" style="cursor: pointer; ">

<div class="input_file_cover" style="width: 249px; height: 23px; cursor: pointer; ">
  <span class="input_file_label" style="left: -4px; height: 21px; cursor: pointer; ">
    Choose File
  </span>
  <div class="file_name" style="height: 21px; cursor: pointer; ">
    File name
  </div>
</div>

Sorry for typos, I have to rush 抱歉打错了,我要赶

您应该尝试基础CSS前端框架应该为您解决问题http://foundation.zurb.com/docs/forms.php

If you know your way around Jquery, that is the best way to create custom elements. 如果您了解使用Jquery的方法,那么这是创建自定义元素的最佳方法。

For custom select buttons I'd suggest using the Jquery library customSelect . 对于自定义选择按钮,我建议使用Jquery库customSelect It lets you create select elements with a variety of things like text boxes inside of the select, radials, etc. 它使您可以创建带有各种内容的选择元素,例如选择框内的文本框,径向线等。

If you want a prebuilt fancy looking file upload with a progress bar, I'd suggest using FancyUpload 如果您希望通过进度条上传预制的精美外观文件,建议您使用FancyUpload

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

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