0

I gave position: absolute; to div.box1 and div.box2 goes under div.box1, but in my html code I wrote div.box2 after the div.box1. Also when I give position: absolute; to div.box2 the red one goes under the blue on. Why?

.container {
  width: 600px;
  height: 200px;
  background-color: #d3d3d3;
}
.box1 {
  width: 100px;
  height: 100px;
  background-color: red;
  position: absolute;
}
.box2 {
  width: 100px;
  height: 100px;
  background-color: blue;
}
<!DOCTYPE html>
<html>
<head>
<title>Positon Property</title>
</head>
<body>
  <div class="container">
    <div class="box1"></div>
    <div class="box2"></div>
  </div>
</body>
</html>
wjatek
  • 819
  • 6
  • 22

0 Answers0