如何将一个元素放置在另一个元素下面? [英] How can I position one element below another?

查看:338
本文介绍了如何将一个元素放置在另一个元素下面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个元素放在另一个元素下.我在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?

推荐答案

只给出位置:相对于第二个div和top:315px或您想要的任何内容

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆