取色器
程序员文章站
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 << " " }
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" %>
上一篇: echarts柱形图
下一篇: easyui 合并单元格(个人笔记)