在bootstrap中col-md-offset-*不起作用

在bootstrap中,使用col-md-offset-1、col-md-offset-2、col-md-offset-3、col-md-offset-4等来设置偏移量很常见,但最近就遇到一个问题了,在最新版的bootstrap4.5中,这个值不起作用了。


 <div class="container">
            <div class="row">
                <div>
                    <h2 class="col-md-4 col-md-offset-1">Browse.</h2>
                    <h2 class="col-md-4 col-md-offset-1">create.</h2>
                    <h2 class="col-md-4 col-md-offset-1">share.</h2>
                </div>
            </div>
        </div> 

这真的是很奇怪啊。后来翻看Bootstrap的官方文档才明白,原来在bootstrap4以后,定义已经发生了变化,我们不需要前缀col-,只是偏移-md-3 这样的写法,也就是不要col-开头了,而是offset-md-3这样的写法。修改成下面的写法就能正常工作了,HOHO,Ye!


<div class="row">
   <div class="offset-md-3 col-md-6"> Some content...
   </div>
</div>



您可能还会对下面的文章感兴趣: