欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

取色器

程序员文章站 2022-07-13 14:28:17
...
  def color_picker(name)
    hexes = []
    (0..15).step(3) do |one|
      (0..15).step(3) do |two|
        (0..15).step(3) do |three|
          hexes << "#" + one.to_s(16) + two.to_s(16) + three.to_s(16)
        end
      end
    end
    arr = []
    10.times { arr << "&nbsp;" }
    returning html = '' do
      html << "<select name=#{name}>"
      html << hexes.collect {|c|
        "<option value='#{c}' style='background-color: #{c}'>#{arr.join}</option>" }.join("\n")
      html << "</select>"
    end
  end

 

具体示例:

 

<%= color_picker "picker" %>

 

相关标签: C C++ C# HTML