html - 修复了 DIV 两侧的按钮高度

标签 html css

我想不通。我需要 2 个按钮来粘住……即使滚动也是如此。该站点使用 Bootstrap。我在桌面和移动 View 中将按钮定位在我想要的位置。但我无法让它们固定在 DIV 的一侧。请提出建议:

<div class="span12">
  <asp:Panel>
    <!-- Buttons -->
    <div style="width:100%; position: relative;">
      <asp:HyperLink runat="server" ID="lnkP"><span style="width:14px; height:60px; position: absolute; top: 65px; left:-4px; text-align: center;"><i class="icon-chevron-left" style="position:relative; top:45%; transform: perspective(1px) translateY(-45%);"></i></span></asp:HyperLink>
      <asp:HyperLink runat="server" ID="lnkN"><span style="width:14px; height:60px; position: absolute; top: 65px; right:-4px; text-align: center;"><i class="icon-chevron-right" style="position:relative; top:45%; transform: perspective(1px) translateY(-45%);"></i></span></asp:HyperLink>
    </div>
    <!-- Main Table -->
    <table style="width: 100%;" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <p>
            The standard Lorem Ipsum passage, used since the 1500s "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
            ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
            laborum."
          </p>
        </td>
      </tr>
    </table>
  </asp:Panel>
</div>

也许我搜索时使用了错误的词。

最佳答案

感谢 Carol 的建议,position:sticky,我能够通过以下方式获得所需的布局:

<div style="position: sticky; top:100px;">
    <div style="width:100%; position: relative;">
        <asp:HyperLink runat="server" ID="lnkP"><span style="width:14px; height:60px; position: absolute; left:-8px; text-align: center;"><i class="icon-chevron-left" style="position:relative; top:45%; transform: perspective(1px) translateY(-45%);"></i></span></asp:HyperLink>
        <asp:HyperLink runat="server" ID="lnkN"><span style="width:14px; height:60px; position: absolute; right:-8px; text-align: center;"><i class="icon-chevron-right" style="position:relative; top:45%; transform: perspective(1px) translateY(-45%);"></i></span></asp:HyperLink>
    </div>
</div>

请注意,我制作了一个额外的 DIV 并将其放在最前面。

关于html - 修复了 DIV 两侧的按钮高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52959588/

相关文章:

HTML/CSS 文本不在框内缩进

javascript - 当光标靠近底部时自动滚动动画

html - 实现 div 并排放置的对 Angular 线切片布局

css - 绝对定位的元素移动了另一个元素的边距

css - 出现滚动条时 FireFox 中的长页面偏移

html - <acronym> 和 <abbr> 的区别?

javascript - 在 jQuery 中将一些项目附加到一个 div,并将其余的附加到另一个 div

php - Css 样式不起作用

css - 我的导航未定义,即使声明了我的文档类型

css - Kendo UI PanelBar - 删除选定面板上的自动样式