2 years ago

#342093

test-img

Alok

How to align child elements of div whose position is absolute to center horizontally?

I want to set child elements to center horizonatally of <div style="position: absolute">

<!DOCTYPE html>
<html>

<head>
  <style>
    #top {
      border: 1px solid yellow;
      position: relative;
      width: 100px;
      height: 100px;
    }

    #mydiv {
      border: 1px solid green;
      position: absolute;
      bottom: 0;
    }

    .item {
      border: 1px solid red;
    }
  </style>
</head>

<body>
  <div id="top">
    <div id="mydiv">
      <span class="item">1</span>
      <span class="item">2</span>
      <span class="item">3</span>
    </div>
  </div>
</body>

</html>

How can I set set all three <span> in center at bottom?

html

css

text-align

0 Answers

Your Answer

Accepted video resources