[英]Displaying a col fixed on left and the other col on the right scrollable using bootstrap 4 css
I have a bootstrap row where I have 2 cols inside it.我有一个引导行,里面有 2 个列。 I need 1 col to be on the left side which should be sticky.
我需要 1 col 在左侧,应该是粘性的。 The col on the right side, I have multiple cards rendered there which contain text and those cards should be scrollable.
右侧的 col,我在那里渲染了多张包含文本的卡片,这些卡片应该是可滚动的。
See the image, The cards like Article and Post should be fixed to that position, but the posts on the right should be scrollable.看图片,文章和帖子之类的卡片应该固定到那个position,但是右边的帖子应该是可滚动的。
The code I have written is this,我写的代码是这样的,
<div class="container-fluid">
<div class="row">
// Row 1 should be on the left
<div class="col-md-3">
<app-articles></app-articles>
<app-navigation></app-navigation>
</div>
// Row 2 should be on the right
<div class="col-md-9">
<div class="card" *ngFor="let post of posts; let i = index"></div>
</div>
</div>
</div>
How do I do this?我该怎么做呢?
If you are using bootstrap 5 then bootstrap by default provide class for same ie sticky-top如果您使用的是引导程序 5,则引导程序默认为相同的即粘顶提供 class
<div class="container-fluid">
<div class="row">
// Row 1 should be on the left
<div class="col-md-3">
<div class="sticky-top">
<app-articles></app-articles>
<app-navigation></app-navigation>
</div>
</div>
// Row 2 should be on the right
<div class="col-md-9">
<div class="card" *ngFor="let post of posts; let i = index"></div>
</div>
</div>
</div>
And if you want to fixed position then replaced the class with fixed-top, but you have to look for alignment while using position fixed, for more information regarding to position classes then refer to the official bootstrap 5 documentations. And if you want to fixed position then replaced the class with fixed-top, but you have to look for alignment while using position fixed, for more information regarding to position classes then refer to the official bootstrap 5 documentations. https://getbootstrap.com/docs/5.2/helpers/position/
https://getbootstrap.com/docs/5.2/helpers/position/
Hope that work for you:)希望对你有用:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.