如何锁定html页面大小???

html-css08

如何锁定html页面大小???,第1张

锁定html页面大小,可以通过插入代码来实现,具体操作代码如下:

第一步、将以下代码加入页面:

<script language=javascript>

function hero()

{

var herowidth=400//改为你要的网页宽度

var heroheight=300//改为你要的网页高度

window.resizeTo(herowidth,heroheight)

}

hero()

</script>

第二步、在<body>中加入:

<body onresize=hero()>

你可以用CSS来设定,DIV为块级元素。例如:

<!doctype html>

<html>

<head>

<meta charset="utf-8' />

<title>设置DIV的固定大小</title>

<!--一下代码是设置DIV固定大小的(宽度:100像素;高度:60像素)-->

<style type="text/css">

    #div {width:100pxheight:60pxborder:1px solid #f00}

</style>

</head>

<body>

<div id="div"></div>

</body>

</html>