我在不同的文件上有两个CSS ID,并且仅当程序在Internet Explorer中执行时,才需要使用另一个ID来更改文件。
我有一个名为“ custom.css”的文件:
#employee-list {
border-bottom: 1px solid #c1c1c1;
border-top: 1px solid #c1c1c1;
height: initial;
}
我需要(我一定不要修改custom.css)将“高度”设置为“自动”。但仅当页面在IE上呈现时。因此,我创建了另一个名为“ customie.css”的css文件:
#employee-list {
border-bottom: 1px solid #c1c1c1;
border-top: 1px solid #c1c1c1;
height: auto;
}
之后,我在MasterPage .cshtml的
<head>
中编写了此条件注释。<!--[if IE]>
<link rel="stylesheet" type="text/css" href="customie.css" />
<![endif]-->
问题是这样的:条件注释不起作用,并且customie.css文件覆盖了custom.css(其自身无效)。
如何仅将
height: auto
应用于IE页面?谢谢,
安杰洛
最佳答案
不知道为什么条件不起作用,但是您可以使用下面的CSS达到所需的效果。 IE不支持initial
,因此它将改回auto
。
#employee-list {
border-bottom: 1px solid #c1c1c1;
border-top: 1px solid #c1c1c1;
height: auto;
height: initial;
}
关于html - 如何在.cshtml母版页中添加条件注释?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45510508/