粘性物品与父母有关
我有一个棘手的侧边栏,我想在父母的课程中保留。这停留在内。Inner
框。
当前,它溢出到.outside
框中。
的JSFIDDLE - https://jsfiddle.net.net/dky2ebyb3m/10/10/10/10/
这是带有示例 :
<div class="parent">
<div class="other">
</div>
<div class="inner">
<nav>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</nav>
<div class="content">
One
</div>
<div class="content two">
TWO
</div>
<div class="content three">
Three
</div>
</div>
</div>
<div class="outside">
</div>
scss
.content {
height: 400px;
background: red;
&.two {
background: green;
}
&.three {
background: grey;
}
}
.other {
height: 300px;
background: yellow;
}
.parent {
//overflow: hidden;
}
nav {
position: sticky;
top: 25%;
left: 100%;
height: 0;
ul {
display: flex;
flex-direction: column;
li {
list-style: none;
position: relative;
background: white;
width: 80px;
height: 80px;
display: block;
border-radius: 10px;
color: #f47324;
}
}
}
.outside {
height: 400px;
background: orange;
}
I have a sticky sidebar that I'm trying to keep inside parent class. That is staying inside the .inner
box.
Currently, it is overflowing into the .outside
box.
Here is the JSFiddle with an example - https://jsfiddle.net/dky2eb3m/10/
HTML:
<div class="parent">
<div class="other">
</div>
<div class="inner">
<nav>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</nav>
<div class="content">
One
</div>
<div class="content two">
TWO
</div>
<div class="content three">
Three
</div>
</div>
</div>
<div class="outside">
</div>
SCSS
.content {
height: 400px;
background: red;
&.two {
background: green;
}
&.three {
background: grey;
}
}
.other {
height: 300px;
background: yellow;
}
.parent {
//overflow: hidden;
}
nav {
position: sticky;
top: 25%;
left: 100%;
height: 0;
ul {
display: flex;
flex-direction: column;
li {
list-style: none;
position: relative;
background: white;
width: 80px;
height: 80px;
display: block;
border-radius: 10px;
color: #f47324;
}
}
}
.outside {
height: 400px;
background: orange;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您希望您的
nav
在内部,然后可以这样做。You want your
nav
to be inside then you can do that like this.