pon un div al lado de otro in javascript

To place one div next to another using JavaScript, you can make use of the style attribute and set the display property to inline-block. Here's an example:

index.tsx
const div1 = document.createElement('div');
const div2 = document.createElement('div');

div1.style.display = 'inline-block';
div2.style.display = 'inline-block';

// set content and other styles for div1 and div2

document.body.appendChild(div1);
document.body.appendChild(div2);
281 chars
11 lines

This will create two div elements and place them next to each other within the body element.

Alternatively, you can also achieve this with CSS by giving both div elements a class name and setting their display property to inline-block in a style block in the head of your HTML document.

<head>
  <style>
    .inline {
      display: inline-block;
    }
  </style>
</head>
<body>
  <div class="inline">Div 1 content</div>
  <div class="inline">Div 2 content</div>
</body>
184 chars
12 lines

related categories

gistlibby LogSnag