我在網站上發現它,但對我來說似乎不起作用。 問題是,CSS不會改變或改變非常快,我可以看到所有的黑色閃光和空白頁面(http://gino.net16.net/inde.php它可以清楚地看到與Firefox)。因爲我有沒有JavaScript技能,所以我不知道什麼是錯的。根據javascript的分辨率更改css文件
主文件
<html>
<head>
<title>my title</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function redirectCSS() {
if ((screen.width == 640) && (screen.height == 480))
{document.write("<link href='style.css' rel='stylesheet' type='text/css'>")}
else if ((screen.width == 800) && (screen.height == 600))
{document.write("<link href='style.css' rel='stylesheet' type='text/css'>")}
else if ((screen.width == 1024) && (screen.height == 768))
{ document.write("<link href='style.css' rel='stylesheet' type='text/css'>")}
else
{document.write("<link href='style.css' rel='stylesheet' type='text/css'>")}
}
// End -->
</script>
</head>
<body onLoad="redirectCSS()">
<h1>Use the appropriate stylesheet to display this content</h1>
</body>
</div>
</html>
css樣式文件
@charset "utf-8";
/* CSS Document */
body {
background-color: #2a2725;
font-family: Arial, Helvetica, sans-serif;
text-shadow: 0px 0px 1px #2a2725;
color: #fff;
}
/* }}} END TableSorter */
它似乎工作在jsfiddle:http://www.jsfiddle.net/vLy3p/。 – Eray 2011-01-29 20:56:15
谷歌爲「CSS媒體查詢」 - 有更簡單的方法來做到這一點! – Pointy 2011-01-29 21:00:48