【问题标题】:Change width of farbtastic color picker does not work for me更改 farbtastic 颜色选择器的宽度对我不起作用
【发布时间】:2016-01-04 00:35:44
【问题描述】:

我非常努力地改变了 farbtastic 颜色选择器的宽度和高度,但没有成功.... JS 不是我的语言

谁能帮帮我

我在http://liveweave.comhtml-online-editor 上尝试了所有可能的解决方案

<!DOCTYPE html>
 <html>
  <head>
   <title>HTML5, CSS3 and JavaScript demo</title>
   <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js'></script>
   <script type='text/javascript' src='http://gilbertsincobh.com/wp-content/plugins/revslider/js/farbtastic/farbtastic.js'></script>
   <link rel='stylesheet' href='http://gilbertsincobh.com/wp-content/plugins/revslider/js/farbtastic/farbtastic.css' type='text/css' />

   <script type='text/javascript'>
    $(document).ready(function(){
                          $('#demo').hide();
                          $('#picker').farbtastic('#color');
                          $.farbtastic("#picker", {callback: pickerUpdate, width: 600, height: 600});
                          function pickerUpdate(color){console.log("Color Picker Wheel: " + color);
                                }
                     );
   </script> 
  </head>
  <body>
   <div id="picker"></div>
  </body>
</html>

【问题讨论】:

  • 你有什么理由使用来自 gilbertsincobh.com 的 farbtastic。似乎宽度和高度在 js 中是硬编码的。所以我只是使用了来自 github repo 的 farbtastic。但它使用旧版本的 jquery。 jsbin.com/tanuji/1/edit?html,css,js,output
  • 感谢您的回复。不,没有理由使用特定来源。我没想到,选择器的大小可以在这个源中硬编码。你的建议很有效,我现在就用它!

标签: javascript jquery css farbtastic


【解决方案1】:

宽度和高度被硬编码到插件源中。只需参考 repo 中的插件源即可。 https://rawgit.com/mattfarina/farbtastic/master/src/farbtastic.js

这应该可行

$(function () {
    $('#colorpicker1').farbtastic('#color1');
    $('#colorpicker2').farbtastic({ callback: '#color2', width: 150 });
});

Here is working demo.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-18
    • 2022-06-14
    • 2012-08-18
    相关资源
    最近更新 更多