<!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';
本文介绍了如何使用CSS内联样式、页级样式和外联链接实现基础布局,同时通过JavaScript动态改变元素高度,展示了两者在网页设计中的交互应用。
1942

被折叠的 条评论
为什么被折叠?



