![](/img/trans.png)
[英]How do a specify the color of a specific table row in an external CSS file?
[英]How do I specify IE 11 specific css file?
我目前有一個頁面,當用戶使用以下html語法單擊打印按鈕時,我正在應用某些瀏覽器特定的CSS樣式。 但是下面的html代碼不會應用為IE11指定的css(ie11print.css),而是應用為其余IE版本(ieprint.css)指定的css。
<!--[if IE 11]> <link rel="stylesheet" media="print" title="Print" type="text/css" href="/styles/ie11print.css" /><![endif]-->
<!--[if lte IE 10]> <link rel="stylesheet" media="print" title="Print" type="text/css" href="/styles/ieprint.css" /><![endif]-->
<!--[if !IE]>--><link rel="stylesheet" media="print" title="Print" type="text/css" href="/styles/print.css" /><!--<![endif]-->
有人知道如何僅為IE11指定CSS文件嗎? 提前致謝。
使用下面的hack,然后是你的css樣式:
*::-ms-backdrop,
例:
*::-ms-backdrop,/*Your element*/ {
/*Your styles*/
}
注意:它只會影響IE瀏覽器。所以你需要在此之前應用你的正常風格。
只需在CSS樣式表中添加以下內容,然后在Internet Explorer 11中查看即可
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none)
{
Add your styles here
}
檢查瀏覽器是否為ie11
然后直接從javascript添加鏈接標記
window.location.hash = !!window.MSInputMethodContext;
if (window.location.hash)
{
var $head = $("head");
var $headlinklast = $head.find("link[rel='stylesheet']:last");
var linkElement = "<link rel='stylesheet' href='/styles/ie11print.css' type='text/css' media='screen'>";
if ($headlinklast.length){
$headlinklast.after(linkElement);
}
else {
$head.append(linkElement);
}
}
如果有任何疑慮,請告訴我。 window.location.hash將為ie11返回true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.