如何将一个元素放置在另一个元素下方?

如何将一个元素放置在另一个元素下方?

问题描述:

我想把一个元素放在另一个元素下.我在 CSS 中使用 position: absolute.

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

 .first{
     width:70%;
     height:300px;
     position:absolute;
     border:1px solid red;
 }
.second{
    border:2px solid blue;
    width:40%;
    height:200px;
}

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

我希望蓝色框位于红色框下方.我怎么能做到这一点?

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

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

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>