<!DOCTYPE html>
<html>
<head>
<style>
body{
margin:0;
}
div{
background-color: gainsboro;
}
</style>
<link rel="stylesheet" type="text/css" href="test.css" />
<link
</head>
<body>
<div id='test' style="width: 100px"></div>
<script type="text/javascript">
var test = document.getElementById('test');
test.style['height'] = window.outerHeight / 2+ 'px';
</script>
</body>
</html>
css样式
1、内联
style=“width: 100px; background-color: red
2、页级
<style>
div{}
<style>
3、外联
<link rel="stylesheet" type="text/css" href="theme.css" />
4、js设置
test.style['height'] = window.outerHeight / 2+ 'px';
test.style.backgroundColor = 'blue';