Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use top in html5

Shulou Source: shulou.com Published: 2022-06-02 05:31:01 10月03日 Update

This article mainly introduces "how to use top in html5". In daily operation, I believe many people have doubts about how to use top in html5. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to use top in html5". Next, please follow the editor to study!

In html5, top means "top" and "distance from the top". The top attribute is used to specify the top edge of the element, and can also be used to set the offset between the upper outer boundary of the positioning element and the upper boundary of its containing block, and the syntax is "" or "Object.style.top= value".

The operating environment of this tutorial: windows10 system, HTML5 version, Dell G3 computer.

What does top mean in html5

The top attribute specifies the top edge of the element. This attribute defines the offset between the upper outer margin boundary of an positioning element and the upper boundary of its containing block.

Note: if the value of the "position" property is "static", setting the "top" property will have no effect.

For the static element, auto; for the length value, the corresponding absolute length; for the percentage value, the specified value; otherwise, auto.

For relative definition elements, if both top and bottom are auto, the calculated value is 0; if one of them is auto, the opposite number of the other value is taken; if both are not auto,bottom, the opposite number of the top value is taken.

The syntax is:

The top attribute sets the offset between the upper outer margin boundary of an positioning element and the upper boundary of its containing block.

The syntax is:

Object.style.top=auto |% | length

Examples are as follows:

Input {position:absolute;} function setTopEdge () {document.getElementById ("b1") .style.top = "100px";}

Tags: Elements attributes boundaries top learning between grammar offset positioning meaning more opposite number edge length help practical next exterior effect tutorial Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker Xiaomi OPPO Reno Shulou Information