The position property for CSS determines which of the positioning schemes is used to calculate the position of a box.
object.style.position = "value"; <'position'> = static | relative | absolute | sticky | fixed static The box is not a positioned box, and is laid out according to the rules of its parent formatting context.
relative The box is laid out as static, then offset from the resulting position.
absolute The box is positioned and sized solely in reference to its absolute positioning containing block. It is taken out of flow, meaning it has no impact on the size or position of its siblings and ancestors, and does not participate in its parent's formatting context.
sticky Identical to relative, except that its offsets are automatically adjusted in reference to the nearest ancestor scroll container's scrollport in whichever axes the inset properties are not both auto, to try to keep the box in view within its containing block as the user scrolls.
fixed Same as absolute, except the box is positioned and sized relative to a fixed positioning containing block.
<!doctype html>
<html>
<head>
<style>
img
{
position: fixed;
right: 50px;
top: 50px;
}
</style>
</head>
<body>
<p>fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed</p>
<img alt="Happy" src="/assets/svg/Happy100.svg">
<p>fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed</p>
<p>fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed</p>
<p>fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed</p>
<p>fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed fixed</p>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
img
{
position: relative;
right: 50px;
top: 50px;
}
</style>
</head>
<body>
<p>relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative</p>
<img alt="Happy" src="/assets/svg/Happy100.svg">
<p>relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative</p>
<p>relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative</p>
<p>relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative</p>
<p>relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative relative</p>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
img
{
position: static;
right: 50px;
top: 50px;
}
</style>
</head>
<body>
<p>static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static</p>
<img alt="Happy" src="/assets/svg/Happy100.svg">
<p>static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static</p>
<p>static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static</p>
<p>static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static</p>
<p>static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static static</p>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
img
{
position: sticky;
right: 50px;
top: 50px;
}
</style>
</head>
<body>
<p>sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky</p>
<img alt="Happy" src="/assets/svg/Happy100.svg">
<p>sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky</p>
<p>sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky</p>
<p>sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky</p>
<p>sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky sticky</p>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
img
{
right: 50px;
top: 50px;
}
</style>
</head>
<body>
<button>initial</button>
<button>absolute</button>
<button>fixed</button>
<button>relative</button>
<button>static</button>
<button>sticky</button>
<p>position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position</p>
<img alt="Happy" src="/assets/svg/Happy100.svg">
<p>position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position</p>
<p>position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position</p>
<p>position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position</p>
<p>position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position position</p>
<script>
function myfunction(myparameter)
{
document.querySelector("img").style.position = myparameter.target.innerHTML;
}
for(const mybutton of document.querySelectorAll("button"))
{
mybutton.addEventListener("mouseover", myfunction);
}
</script>
</body>
</html>