I want to be able to click on the label to check my element without showing the checked so I wrote this:
input[type="checkbox"]
{
display: none;
}
But when I click it doesn't work. It only works if the element is already in the database.
Do I have to do javascript or can CSS do it?
#views/values/edit.html.erb*
<% @values =["Power", "Independance", "Tradition"] %>
<%= form_for @resultvalue do |f| %>
<% @values.each do | value | %>
<%= f.check_box :values, { multiple: true }, value, type:"checkbox" %>
<%= f.label value %>
<% end %>
<%= f.submit%>
<% end %>
input[type="checkbox"]{
display: none;
}
input[type="checkbox"]+label{
transition: all 300ms ease;
font-size: 1.2rem;
cursor: pointer;
border-radius: 1rem;
border: 3px solid white;
background-color: #0066cc;
padding: 0.5rem 1rem;
display: inline-block;
color: white;
// Suggested by @zizzo to prevent text selection
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
// ------------------------
}
input[type="checkbox"]:checked+label{
transition: all 300ms ease;
background-color:#b70e7e;
}