[英]Position:absolute div inside another position:absolute div and making them position:fixed
HTML 的HTML
<div class="div1"></div>
<div class="div2">
<div class="div3"></div>
</div>
CSS 的CSS
Properties of div1,div2 and div3 are: div1,div2和div3的属性为:
div1. {
position: absolute;
z-index: 100;
background-color: rgba(39, 39, 39, 0.3);
height: 90px;
width: 712px;
left: 0px;
bottom: 216px;
}
.div2 {
position: relative;
}
.div3 {
position: absolute;
bottom: 263px;
margin-left: 50px;
}
Now according to my concept is div1 is absolute and I should place div3 inside div1 by making it as absolute.Now my problem is I need to make div1 as position:fixed and it should be there if I scroll it but If I give like that the div 3 is not fixed and it is moving .Can I get the tricky point for this 现在根据我的概念是div1是绝对的,我应该将div3设置为绝对。现在我的问题是我需要将div1设置为position:fixed,如果滚动它应该在div1上,但是如果我给出div 3是不固定的,它正在移动。
Change position for both div1 and div3 to fixed and they will stay put when scrolling. 将div1和div3的位置都更改为固定,滚动时它们将保持原状。 There is also a minor typo in the CSS for div1 (the period is placed after instead of before "div1").
CSS中还有一个针对div1的小错字(句点位于“ div1”之后而不是之前)。
.div1 {
position: fixed;
z-index: 100;
background-color: rgba(39, 39, 39, 0.3);
height: 90px;
width: 712px;
left: 0px;
bottom: 216px;
}
.div2 {
position: relative;
}
.div3 {
position: fixed;
bottom: 263px;
margin-left: 50px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.