Comment

Comment by dmarlow

ChatGPT response:

center two <div> side-by-side

To center two <div> elements side-by-side, you can use the following CSS code:

Copy code

  <style>
    .container {
      display: flex;
      justify-content: center;
    }
    .left-div {
      margin-right: 20px;
    }
  </style>

  <div class="container">
    <div class="left-div">
      Content for left div
    </div>
    <div class="right-div">
      Content for right div
    </div>
  </div>
Here, the .container class is used to wrap the two <div> elements, and the display: flex property is applied to center the <div> elements horizontally. The justify-content: center property is also used to align the <div> elements to the center of the container. The left-div class is used to add a margin to the left <div> element, so that it is not touching the right <div> element.
parent dmarlow 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton