JavaScript 调整DIV的大小
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 调整DIV的大小相关的知识,希望对你有一定的参考价值。
<html>
<head>
<style type="text/css">
* a { outline: none; }
body { font: 14px Arial, Verdana, sans-serif; text-align: center; }
div { border: 1px solid #ccc; border-bottom-width: 3px; border-right-width: 3px; padding: 100px 0; width: 300px; margin: 10px auto; }
.maior { width: 99%; }
input { margin: 10px auto; }
</style>
</head>
<body>
<div id="campo" class="">Normal div</div>
<input type="button" value="Make it wider" onClick="aumentaDiv()" />&nbsp;&nbsp;
<input type="button" value="Make it normal" onClick="diminuiDiv()" />
<script type="text/javascript">
var campoAtivo = document.getElementById("campo");
function aumentaDiv() {
campoAtivo.className = "maior";
campoAtivo.innerHTML = "Wider div";
}
function diminuiDiv() {
campoAtivo.className = "";
campoAtivo.innerHTML = "Normal div";
}
</script>
</body>
</html>
以上是关于JavaScript 调整DIV的大小的主要内容,如果未能解决你的问题,请参考以下文章