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

170
Views
JS: agregó un botón pero necesita ayuda para establecer su posición

Estoy tratando de agregar un botón con JS a la etiqueta HTML div, después de agregarlo, me gustaría establecer su posición en la esquina derecha:

ingrese la descripción de la imagen aquí

Pero cuando agregué margin-left, bajó una línea.

¿Cómo puedo arreglar esto?

el código:

 function CheckForm(){ let form = document.getElementById('fcf-form-id'); if (form['Email'].value == "") { let x = document.getElementById('error-msg'); const button = document.createElement('BUTTON'); button.innerHTML = 'X'; x.innerHTML = "I need you to enter you Email in order to get back to you." x.appendChild(button); button.style.marginLeft ='95%'; x.setAttribute("style" , "opacity:1"); button.addEventListener('click' , () => { x.innerHTML =""; x.setAttribute("style" , "opacity:0"); } ) return false; }
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Configure el envoltorio para que sea relativo, configure el botón para que sea absoluto y configure la parte superior e izquierda.

 .error { position: relative; background-color: yellow; border: 1px solid black; } .error .message { padding-left: 1em; } .error .close { position: absolute; top: 0; right: 0; }
 <div class="error"> <p class="message"> Hello World. It is foo. </p> <button class="close">x</close> </div>

about 4 years ago · Santiago Trujillo Report

0

¿Puedes compartir el código para esto? Debe asegurarse de usar una relación de escala confiable como % y puede configurar el atributo de visualización del botón para bloquear en línea

 display: inline-block;
about 4 years ago · Santiago Trujillo 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!