HTML DOM top ÊôÐÔ

HTML DOM Style ¶ÔÏó

¶¨ÒåºÍÓ÷¨

top ÊôÐÔÉèÖÃÒ»¸ö¶¨Î»ÔªËصÄÉÏÍâ±ß¾à±ß½çÓëÆä°üº¬¿éÉϱ߽çÖ®¼äµÄÆ«ÒÆ¡£

Óï·¨£º

Object.style.top=auto|%|length

¿ÉÄܵÄÖµ

Öµ ÃèÊö
auto ĬÈÏ¡£Í¨¹ýä¯ÀÀÆ÷À´¼ÆËã¶¥²¿µÄλÖá£
% ÉèÖÃÔªËØµÄ¶¥²¿µ½×î½üÒ»¸ö¾ßÓж¨Î»ÉèÖø¸ÔªËصÄÉϱßÔµµÄ°Ù·Ö±ÈλÖá£
length ʹÓà px¡¢cm µÈµ¥Î»ÉèÖÃÔªËØµÄ¶¥²¿µ½×î½üÒ»¸ö¾ßÓж¨Î»ÉèÖÃÉϱßÔµµÄ¶¥²¿µÄλÖ᣿ÉʹÓøºÖµ¡£

ÌáʾºÍ×¢ÊÍ

×¢ÊÍ£ºÈç¹û "position" ÊôÐÔµÄֵΪ "static"£¬ÄÇôÉèÖà "top" ÊôÐÔ²»»á²úÉúÈκÎЧ¹û¡£

ʵÀý

±¾ÀýÉèÖÃÔªËØµÄÉϱ߽磺

<html>
<head>
<style type="text/css">
input
{
position:absolute;
}
</style>
<script type="text/javascript">
function setTopEdge()
{
document.getElementById("b1").style.top="100px";
}
</script>
</head>
<body>

<input type="button" id="b1" onclick="setTopEdge()"
value="Set top edge to 100 px" />

</body>
</html>

HTML DOM Style ¶ÔÏó

VUE