css - IE11 不应用媒体查询
问题描述
在一个p-dialog
类中,它在 Chrome、Firefox 和 IE Edge 上运行良好,但在 IE<=11 中无法正常运行。
<p-dialog [baseZIndex]="10000" [contentStyle]="{'overflow':'visible'}" responsive="true" modal="true" #noteView
[(visible)]="displayModal" [appendTo]="'body'" (onShow)="onAfterShow($event)" class="example-dialog">
</p-dialog>
这是我的 CSS 上的媒体查询
@media all and (min-width: 1024px) and (-ms-high-contrast: active), (-ms-high-contrast: none) {
::ng-deep .example-dialog .ui-dialog {
width: 60%;
height: 50%;
overflow-y: auto;
}
}
我该如何解决这个问题?
解决方案
@media all and (min-width: 1024px) and (-ms-high-contrast: active), (-ms-high-contrast: none) { }
经测试,上述CSS样式适用于IE10+浏览器。您可以检查以下示例:
<style>
@media all and (min-width: 1024px) and (-ms-high-contrast: active), (-ms-high-contrast: none) {
.content {
width: 100%;
height: 50%;
overflow-y: auto;
background-color: darkseagreen;
}
}
</style>
<div class="content">content</div>
有关使用 CSS 样式检测浏览器的更多详细信息,请查看此链接:How to target only IE (any version) within a stylesheet?
此外,请检查您的代码,您似乎正在使用类选择器来设置 CSS 样式,但是在媒体部分,您没有为“example-dialog”类添加 CSS 样式。请尝试如下修改。
@media all and (min-width: 1024px) and (-ms-high-contrast: active), (-ms-high-contrast: none) {
.example-dialog {
width: 60%;
height: 50%;
overflow-y: auto;
}
}
推荐阅读
- faunadb - 动物区系按参考搜索
- scala - 如何在Scala中映射函数的输入?
- android - 来自 FireStone 的 TextView 中的消息
- intellij-idea - 在 IntelliJ 中,使用光标前的表达式作为参数调用函数的快捷方式是什么
- python - 在 Windows 10 中使用 python 在文件中输出 Git 命令
- github - 如何为特定用户创建的标记问题创建 Github 操作?
- amazon-web-services - AWS SQS 队列中可以存储的最大消息量是多少?
- c# - 这是我得到 System.Data.SqlClient.SqlException 的错误:'Table' 附近的语法不正确。'。有人可以帮忙
- linux - Heroku 部署和 pyodbc
- ios - SwiftUI 如何构建多个导航链接