如何将一个元素放置在另一个元素下方? [英] How can I position one element below another?
本文介绍了如何将一个元素放置在另一个元素下方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想把一个元素放在另一个元素下.我在 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>
这篇关于如何将一个元素放置在另一个元素下方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文