gpt4 book ai didi

javascript - 绝对位置第二次不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 23:42:52 24 4
gpt4 key购买 nike

我有 3 个 div,我希望在单击每个 div 底部的箭头时它们可以相互滚动。由于 height: 100vh

,每个 div 都占据了整个浏览器高度

由于 style="position: absolute; bottom: 0; right: 0; left: 0,每个箭头都粘在当前 div 的底部(因此,粘在浏览器页面的底部) ; 边距:自动;"

问题是只有第一个箭头粘在第一个 div 的底部,第二个 div 上的第二个箭头没有显示,即使这些 div 的结构几乎相同。因此,第一个箭头滚动到最后一个 div,而不是第二个 div。

最后但同样重要的是,我的垂直对齐似乎不起作用(在每个 span12 下方),我想设置一个箭头以滚动到顶部的第一个 div我的第二个分区

这是 FIDDLE

代码:

<!-- FIRST DIV -->
<div id="explanation" class="row-fluid" style="height: 100vh;">
<div class="span12" style="height:100%; display:table !important;">
<!-- Vertical Align center -->
<div style="display:table-cell; vertical-align:top;">
<h1 class="visible-phone" style="text-align:center;margin: 10px 0;">
Title - Explanation
</h1>
<hr style="width: 50%; margin-left: 25%;" />
<div class='container' style="padding-top: 10%;">
<div class="span3">
<h2>Sub-Title:</h2>
</div>
<div class="span9">
<h4>
<p>
This is my subtitle
</p>
</h4>
</div>
</div>
</div>
</div>
<div style="position: absolute; bottom: 0; right: 0; left: 0; margin: auto;">
<div class="circle-box-blue show_link_css">
<a href="#form1"><h1 class="icon-chevron-down icon-large"></h1></a>
</div>
</div>
</div>


<!-- SECOND DIV -->
<div id="form1" class="row-fluid" style="height: 100vh;">
<div class="span12" style="height:100%; display:table !important;">
<!-- Vertical Align center -->
<div style="display:table-cell; vertical-align:top;">
<h1 class="visible-phone" style="text-align:center;margin: 10px 0;">
Title - Form1
</h1>
<hr style="width: 50%; margin-left: 25%;" />
<div class='container' style="padding-top: 10%;">
<div class="span3">
<h2>Sub-Title:</h2>
</div>
<div class="span9">
<h4>
<p>
This is my subtitle, for my form1
</p>
</h4>
</div>
</div>
</div>
</div>
<!-- THIS ARROW ISNT EVEN BEING DISPLAYED! -->
<div style="position: absolute; bottom: 0; right: 0; left: 0; margin: auto;">
<div class="circle-box-blue show_link_css">
<a href="#button"><h1 class="icon-chevron-down icon-large"></h1></a>
</div>
</div>
</div>

<!-- LAST DIV -->
<div id="button" class="row-fluid" style="height: 100vh;">
<div class="span2">Last Div</div>
</div>

非常感谢任何帮助,谢谢。

最佳答案

position: absolute; 绝对定位元素相对于最近定位的祖先。在你的例子中,因为你的包装器 div 没有定位,这意味着箭头相对于页面定位,所以它们都在同一个地方。

尝试将 position: relative 添加到包装 div。

关于javascript - 绝对位置第二次不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22376945/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com