Bootstrap col固定位置 [英] Bootstrap col fixed position
问题描述
我怎样才能修复Bootstrap col。
How can I fix Bootstrap col.
我试过这样但它不起作用:
I tried like this but it is not working:
<div class="row">
<div class="col-md-6">Content goes here...</div>
<div class="col-md-6" style=" position: fixed">Content goes here...</div>
</div>
固定位置
位置使col成为绝对位置。
fixed
position makes col as absolute position.
如何禁用固定位置,当页面从顶部400px向下滚动时。
And how can I disable a fixed position, when the page is scrolled down from top 400px.
推荐答案
使用媒体查询只应用特定屏幕宽度以上的固定位置。例如,768px是Bootstrap 4 md
断点:
Use media query to only apply the fixed position above a specific screen width. For example 768px is the Bootstrap 4 md
breakpoint:
CSS( min-height
是可选的):
CSS (min-height
is optional):
@media (min-width: 768px) {
.fixed-posi {
width: 50%;
margin-left: 50%;
min-height:100%;
position:fixed;
}
}
然后,使用 fixed- posi
在这样的布局中...
Then, use fixed-posi
in the layout like this...
<div class="row">
<div class="col-md-6">
Content goes here...
</div>
<div class="col-md-6 fixed-posi">Content goes here... (fixed position)
</div>
</div>
演示: https://www.codeply.com/go/751CygARyO
类似的问题(左侧固定DIV):如何左栏固定和右卷轴Bootstrap 4,回应?
Similar question (fixed DIV on left): How to left column fixed and right scrollable in Bootstrap 4, responsive?
这篇关于Bootstrap col固定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!