備忘錄_20160105(定位)
修改
回首頁
程式 2024-03-21 17:04:40 1711011880 100
js 動態決定 CSS, dynamic css
js 動態決定 CSS, dynamic css
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link id="mylink" rel="stylesheet" type="text/css">
</head>
<body>
<div><button type="button" onclick="load_style();">load_style</button></div>
<div id="div1">中文字!Hello, world!</div>
<script>
function load_style()
{
document.getElementById('mylink').href
="data:text/css;base64,"
+btoa("#div1 { font-size: 24pt; color: red; }");
}
</script>
</body>
</html>