Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
Add a tick selected css

.showcase-components-colorlist color {
  border: 2px solid transparent;
  margin: 1px;
  padding: 2px;
  border-radius: 50%;
  cursor: pointer;
}
<div class="showcase-components-colorlist color showcase-components-colorlist color-- active">
  <svg width="40" height="40">
    <circle cx="20" cy="20" r="19" fill="#c5145d" stroke="#fff" stroke-width="1"></circle>
  </svg>
</div>
<div class="showcase-components-colorlist color">
  <svg width="40" height="40">
    <circle cx="20" cy="20" r="19" fill="#db2586" stroke="#fff" stroke-width="1"></circle>
  </svg>
</div>

How to add a check mark to one of the circles as generated by the code above.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

One way to do this is through pseudo content. You need to give the element which you'll set the pseudo content a relative container. Then, you create your pseudo content (in this case, a check mark). The positioning will be relative to the parent element's dimensions.

.showcase-components-colorlist {
  border: 2px solid transparent;
  margin: 1px;
  padding: 2px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
}

.showcase-components-colorlist.selected::before {
  content: '✅';
  position: absolute;
  left: 11px;
  top: 9px;
}
<div class="showcase-components-colorlist color showcase-components-colorlist color-- active">
  <svg width="40" height="40"><circle cx="20" cy="20" r="19" fill="#c5145d" stroke="#fff" stroke-width="1">
    </circle>
  </svg>
</div>
<div class="showcase-components-colorlist selected">
  <svg width="40" height="40">
    <circle cx="20" cy="20" r="19" fill="#db2586" stroke="#fff" stroke-width="1"></circle>
  </svg>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

Create your own <svg-option> Native JavaScript Web Component.

<svg-option></svg-option>
<svg-option fill="red" selected></svg-option>
<svg-option fill="rebeccapurple" selected-fill="yellow" selected></svg-option>

creates:

<script>
customElements.define("svg-option",class extends HTMLElement{
  connectedCallback(){
    this.style.display = "inline-block";
    this.innerHTML=`<svg viewBox="0 0 50 50">
                      <circle cx="50%" cy="50%" r="49%" fill="${this.getAttribute("fill") || "green"}"/>
                      <circle cx="50%" cy="50%" r="30%" fill="${this.getAttribute("selected-fill") || "beige"}" visibility="hidden"/>
                    </svg>`;
    this.select();
    this.onclick = (evt) => this.toggle();
  }
  select(state = this.hasAttribute("selected")) {
    this.querySelector("circle:nth-child(2)").setAttribute("visibility" , state ? "visible" :"hidden");
  }
  toggle(){
    this.select( this.toggleAttribute("selected") );
  }
})
</script>

<style>
  svg-option {
    --svg-option-size:180px;
    width: var(--svg-option-size);
    height: var(--svg-option-size);
    cursor: pointer;
  }
  svg-option[selected]{
    background:lightgreen;
  }
  svg-option:not([selected]){
    background:pink;
  }
</style>

<svg-option></svg-option>
<svg-option fill="red" selected></svg-option>
<svg-option fill="rebeccapurple" selected-fill="yellow" selected></svg-option>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda