取色器

  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" %>

 

你可能感兴趣的:(html,C++,c,C#)