栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使图像在Bootstrap中居中

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使图像在Bootstrap中居中

更新2018

Bootstrap 2.x

您可以创建一个新的CSS类,例如:

.img-center {margin:0 auto;}

然后,将其添加到每个IMG:

 <img src="images/2.png" >

或者,

.img-responsive
如果要将所有图像居中,则只需覆盖即可。

 .img-responsive {margin:0 auto;}

演示: http
//bootply.com/86123

Bootstrap 3.x

编辑 -随着Bootstrap 3.0.1的发布,

center-block
现在可以使用该类,而无需任何其他CSS。

 <img src="images/2.png" >

引导程序4

在Bootstrap 4中,

mx-auto
该类(自动x轴边距)可用于将图像居中
display:block
。但是,img是
display:inline
默认设置,因此
text-center
可以在父级上使用。

<div >    <div >        <div > <img  src="//placehold.it/200">          </div>    </div>    <div >        <div > <img src="//placehold.it/200">          </div>    </div></div>

Bootsrap 4-中心图像演示



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/420895.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号