css - IE / ME - 使用 Boostrap 4 将中间按钮文本与 flex 垂直对齐
问题描述
按钮中的文字应该在中心,但使用Internet Explorer显示在顶部,这是怎么回事?
button {
height: 100px;
}
<div class="container">
<button class="w-100 f-default-f btn btn-primary d-flex justify-content-between px-3">
<div>Text</div>
<div>icon</div>
</button>
</div>
我添加了一个带有 Boostrap 4 alpha 的代码笔,代码如下:
https://codepen.io/anon/pen/PaqLNm
它适用于 Mozilla Firefox 和 Chrome,而 Microsoft Edge 或 Internet Explorer 则没有所需的行为。
解决方案
您正在使用 flex,并且由于存在大量错误,因此 flex 在 IE11 上只有部分支持。
例如,IE 10-11在用于确定弹性项目的大小content
时总是假定一个盒子模型flex-basis
,即使该项目设置为box-sizing: border-box
.
其他已知错误:
-IE 11 需要将一个单位添加到第三个参数,即flex-basis
属性(更多信息)
- 在 IE10 和 IE11 中,如果容器具有但没有显式属性display: flex
,flex-direction: column
则容器将不会正确计算其伸缩子项的大小。min-height
height
min-height
-IE 11使用时不能正确垂直对齐项目
来源: https ://github.com/philipwalton/flexbugs#7-flex-basis-doesnt-account-for-box-sizingborder-box https://developer.mozilla.org/en-US/docs/Web/CSS /flex 基础 https://caniuse.com/#search=flex
推荐阅读
- mqtt - MQTT 送达确认
- python - 这个删除函数的时间复杂度是多少?
- sql - 通过关键变量分组从长表中选择案例
- ios - React native firebase mlkit 人脸检测器适用于 android 但不适用于 iOS
- ipython - 如何在 Web 界面中移动 jupyterlab 笔记本?
- javascript - 'TypeError: 赋值右侧不能被解构' useContext React Hooks
- java - 出队方法未正确删除队列中的元素
- javascript - 如何使用 Node.js 通过请求或 HTTP 在 foreach 循环中下载文件?
- ios - 解析从服务器获取图像(getDataInBackground 不起作用)
- swift - Flask API 的 URLSession 未进入会话