claviska / jquery-minicolors

jQuery MiniColors Plugin
MIT License
956 stars 312 forks source link

getting a checked image when selecting a preset swatch #278

Open ashutosh215 opened 5 years ago

ashutosh215 commented 5 years ago

hi i was wondering if we can get a checked mark on the selected swatch from the preset swatches

claviska commented 5 years ago

You can do this in your stylesheet using the following selector:

.minicolors-swatch.selected {
  /* your checkmark styles here */
}

You may want to take advantage of the ::before or ::after pseudo selector to achieve this.

ashutosh215 commented 5 years ago

hey i know its too much to ask but can you please write it for me please. i tried but i failed i want to add a check mark to the selected swatch

Bhoft commented 4 years ago

Try this:

image

.minicolors-swatch.selected:after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: solid #000;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-left: 40%;
  margin-top: 20%;
}
Bhoft commented 4 years ago

Or better using the html code instead of painting with css (solution from above). https://www.toptal.com/designers/htmlarrows/symbols/check-mark/

image

.minicolors-swatch.selected:after {
    content: "\2713";
    color:black;
    position: relative;
    margin: auto 20%;
}