How can I position one element below another?

khalid J-A picture khalid J-A · Nov 18, 2016 · Viewed 99.7k times · Source

I want to put one element under another element. I am using position: absolute in CSS.

I want the blue box to be positioned under the red box. How could I achieve this?

Answer

Mudassar Saiyed picture Mudassar Saiyed · Nov 18, 2016

just give position : relative to second div and top:315px or what ever you want

.first{
     width:70%;
     height:300px;
     position:absolute;
     border:1px solid red;
 }
.second{
    border:2px solid blue;
    width:40%;
    height:200px;
	position: relative;
    top: 315px;
}
<html>
<head>

</head>
<body>
<div class="first"></div>
<div class="second"></div>
</body>
</head>