【发布时间】:2019-07-06 18:07:40
【问题描述】:
我有一个位置:固定的 div,但是当我滚动底部的窗口时,div 与页脚重叠。我不希望 div 与页脚重叠。
我应该在 css 中做出哪些改变来克服这个问题。
a.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="a.css">
</head>
<body>
<div class="contain">
<div class="data1"></div>
<div class="data"></div>
</div>
<div class="footer"></div>
</body>
</html>
a.css
.contain {
margin-bottom: 35rem;
}
.data {
background-color: red;
width: 30%;
margin-top: -33%;
position: fixed;
height: 600px;
}
.data1 {
width: 30%;
height: 500px;
margin-left: 60%;
background-color: black;
}
.footer {
background-color: blue;
width: 100%;
height: 150px;
bottom: 0;
}
【问题讨论】:
-
请分享您的代码,这将有助于理解问题。
-
@bart 添加了我的代码
-
只是将否定的
margin-top增加到34%? -
对不起,我的意思是
-34%