我面临着使用html和css将一个元素定位在另一个元素上的问题
我有两个div元素,我想把第二个元素的一部分放在第一个元素的顶部,因为我给出了相对于第二个元素的位置,从底部50px开始。但我在第二个元素之后放置了另一个div,我在两者之间获得了一些空间。如何避免这个空间 这是我的代码示例我面临着使用html和css将一个元素定位在另一个元素上的问题,html,css,Html,Css,我有两个div元素,我想把第二个元素的一部分放在第一个元素的顶部,因为我给出了相对于第二个元素的位置,从底部50px开始。但我在第二个元素之后放置了另一个div,我在两者之间获得了一些空间。如何避免这个空间 这是我的代码示例 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8">
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div style="height:100px;background-color:red;"></div>
<div style="height:100px;background-color:green;width:250px;margin:0 auto;position:relative;bottom:50px;"></div>
<p style="text-align:center;">Hello am here</p>
</div>
</body>
</html>
引导示例
您好,我在这里
移除
位置:相对;底部:50px
并替换为边距:-50px自动0代码>
如果有效,请告诉我。
干杯 移除位置:相对;底部:50px
并替换为边距:-50px自动0代码>
如果有效,请告诉我。
干杯