ubicar los elementos del accordion-header en el centro con css in javascript

Assuming you are using a standard accordion-header class with display: flex, you can add the following JavaScript code to center the child elements within the header:

index.tsx
const headers = document.querySelectorAll('.accordion-header');

for (let i = 0; i < headers.length; i++) {
  const header = headers[i];
  header.style.justifyContent = 'center';
  header.style.alignItems = 'center';
}
219 chars
8 lines

This code selects all elements with the accordion-header class and applies the justify-content: center and align-items: center properties to center the child elements within the header.

Alternatively, you can add the following CSS code to a stylesheet:

.accordion-header {
  display: flex;
  justify-content: center;
  align-items: center;
}
89 chars
6 lines

This code sets the display property to flex and applies the justify-content: center and align-items: center properties to center the child elements within the header.

related categories

gistlibby LogSnag