Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

311
Views
Añadir un css seleccionado tick

 .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>

Cómo agregar una marca de verificación a uno de los círculos generados por el código anterior.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Una forma de hacerlo es a través de pseudocontenido. Debe darle al elemento en el que establecerá el pseudo contenido un contenedor relative . Luego, crea su pseudo contenido (en este caso, una marca de verificación). El posicionamiento será relativo a las dimensiones del elemento padre.

 .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 Report

0

Cree su propio componente web JavaScript nativo <svg-option> .

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

crea:

 <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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!