【发布时间】:2019-10-04 11:18:41
【问题描述】:
我的网页需要在现代浏览器(例如 Chrome)和旧版浏览器(例如 IE11)上运行。
大部分都可以,但是当我尝试使用calc (left: calc(50% - 40px);) 将按钮放在父容器div 的中间时,它在IE11 中不起作用,而是放在父容器之外。
这是我的 CSS 代码:
.buttonContainer {
position: fixed;
width: 336px;
height: 62px;
background-color: #fff;
display: inline-block;
text-align: center;
vertical-align: middle;
margin-bottom: 10px;
box-shadow: 0 0 2px 0 #d2d2d2;
}
.button {
position: fixed;
left: calc(50% - 40px);
.color {
background-color: #ff0033;
color: #ffffff;
display: inline-block;
height: 26px;
width: 64px;
margin-top: 10%;
padding: 8px 16px;
font-size: 14px;
cursor: pointer;
text-align: center;
vertical-align: middle;
line-height: 28px;
}
}
以上内容适用于现代浏览器,其中.button 将位于buttonContainer 的中间,但在 IE11 中它将位于其外部。
【问题讨论】:
-
你确定这是 CSS 吗?我问这个是因为 CSS nesting selectors isn't possible in CSS.
-
可能他使用了预处理器
-
是的,我使用 SASS。
标签: html css internet-explorer sass cross-browser