代码编辑器:
x
1
<style>
2
div{
3
border: 1px solid #FF0000;
4
}
5
</style>
6
<script>
7
function changeMargin(){
8
document.getElementById("ex1").style.marginLeft="100px";
9
}
10
function changePadding(){
11
document.getElementById("ex2").style.paddingLeft="100px";
12
}
13
</script>
14
<div id="ex1">这是一些文本</div>
15
<br>
16
<button type="button" onclick="changeMargin()">修改div元素的左部外间距</button>
17
<br>
18
<br>