gpt4 book ai didi

html - 为什么我的 div 不在词缀菜单中滚动?

转载 作者:行者123 更新时间:2023-11-28 04:49:48 24 4
gpt4 key购买 nike

我有一个右侧边栏,用于购物车。我面临的问题是当 bootstrap 添加“affix”类,然后出现溢出,即使我将 item-cont-scroll 类设置为自动滚动,内容也不会滚动

最终总是发生的是内容在底部被截断

我已经尝试了一天,让溢出滚动,但似乎仍然找不到解决方案。我已将高度设置为 100%,创建了一个具有相对位置的父 div,仍然不起作用,

我已经尝试了很多方法,但我似乎无法找到一种方法让它发挥作用。

下面的链接是另一个网站的示例,它已经包含了我正在努力实现的目标。如果您单击链接并选择取货订单,您会看到侧边栏是固定的,当您将更多食品添加到购物车时,它们将被添加到购物车。

https://www.grubhub.com/restaurant/bareburger-85-2nd-ave-new-york/266100

下面是我实际代码的简要概述。你会注意到当你滚动到设置为 130px 的偏移量时,购物车将被切断

我真的很困惑为什么这不起作用。下面是我的页面的代码和我的 js fiddle 的链接

非常感谢任何帮助

https://jsfiddle.net/eldan88/7gyk8hm4/#&togetherjs=Iq2LrSwBUP

 <style>


.categories {

border-bottom: solid 1px lightgray;

}


#item-cont-scroll{

overflow: auto;

}

header{
height: 200px;
}

.affix{
top:0;
}

</style>

</head>
<body>



<article class='container'>

<header>
Logo goes here
</header>

<div class='row'>

<div class='col-sm-8'>


<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>
<h2 class='categories'> Test</h2>



</div>


<div class='col-sm-4'>


<section data-spy='affix' data-offset-top='130' >



<h1> Item name </h1>

<h2> Item Description </h2>
<div id='item-cont-scroll'>
<h2>Option Category 1 </h2>

<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>

<h2>Option Category 2 </h2>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>

<h2>Option Category 3 </h2>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>
<div> Item options </div>



</div>
</section>



</div>


</div>

</article>

最佳答案

添加到#item-cont-scroll height: 100vh;

或者如果您更喜欢百分比 height: 100%; #it​​em-cont-scroll 元素及其父元素 ( <section> )。

关于html - 为什么我的 div 不在词缀菜单中滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40774892/

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