html - 使用引导程序时,为什么我的 div 不在父行中居中?
问题描述
所以我试图通过在父级myCol
上使用align-items-center
我的绿色 div 垂直row
居中,但它没有居中,我不知道为什么。
为什么它会这样?
.myRow {
height: 30vh;
border: orange dotted 2px;
}
.myCell {
width: 100px;
height: 100px;
background: green;
border: blue dotted 3px;
}
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet"/>
<div class="container">
<div class="row align-items-center myRow">
<div class="col-3 myCell">
</div>
</div>
<div class="row myRow">
<div class="col-4 myCell">
</div>
</div>
</div>
解决方案
您的代码的问题是您使用的是 Bootstrap 版本 2,而您应该使用的是 Bootstrap 版本 4。
只需替换引导脚本和 css 文件的链接,它应该可以工作。
推荐阅读
- symfony - Symfony 中默认缓存的文件有哪些
- javascript - 使用 Nodejs 将 JSON 映射到 MongoDB
- java - 调用 init 方法失败;嵌套异常是 java.lang.IllegalArgumentException:需要命名空间属性
- excel - 使用公式提取具有相同行名的所有信息(不同)形成一个excel工作表
- html - 在 Edge 中禁用视频自动播放并在 IE 中禁用下载
- ios - 在 Swift 中取消可选计时器的语法
- c# - ASP.NET Core Identity UserManager 使用 FindByEmailAsync 查找不存在的用户
- regex - 当任何字符串至少包含三个字符并且 + 号被最少三个字符包围时匹配的正则表达式
- python - Tkinter 将图像放入框架,背景
- ats - 在堆栈上分配数据类型