Apply position property on different HTML elements
<style>
div{
position: static;
border: 3px solid #73AD21;
}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
p{
position: static;
border: 5px solid black;
}
</style>
</head>
<body>
<p>TDB Tutorials</p>
</body>
</html>
<style>
div{
position: relative;
right: 30px;
border: 5px solid black;
}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
p{
position: absolute;
border: 5px solid black;
bottom:0;left:0;
}
div{
position: relative;
height:400px;
border: 2px solid red;
}
</style>
</head>
<body>
<div>
<p>TDB Tutorials</p>
</div>
</body>
</html>
<style>
div{
position: fixed;
bottom: 0;
right: 0;
width: 100px;
border: 5px solid black;
}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
body{height:1000px}
p{
position: fixed;
bottom: 0;
right: 0;
width: 100px;
border: 5px solid black;
}
</style>
</head>
<body>TDB EDITOR
<p>TDB Tutorials</p>
</body>
</html>
<style>
.parent-class{
position: relative;
right: 30px;
border: 5px solid black;
width:200px;
height:200px;
}
.child-class{
position: absolute;
top: 20px;
left:20px;
width: 50px;
height: 50px;
border: 5px solid red;
}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
.parent{
position: relative;
border: 5px solid black;
width:200px;
height:200px;
}
.child{
position: absolute;
top: 20px;
left:20px;
width: 50px;
height: 50px;
border: 5px solid red;
}
</style>
</head>
<body>
<div class="parent"><div class="child"></div></div>
</body>
</html>
<style>
div{
/* Safari */
position: -webkit-sticky;
position: sticky;
top: 0;
background-color: green;
border: 5px solid black;
}
</style>
Note: Not suppored by Internet Explorer, Edge 15 and earlier versions.
<!DOCTYPE html>
<html>
<head>
<style>
body{height:1000px}
div{
/* Safari */
position: -webkit-sticky;
position: sticky;
top: 0;
background-color: white;
border: 5px solid black;
}
</style>
</head>
<body>
Simple example of sticky position.<br>
Tdb Editor
<div>TDB Tutorials</div>
</body>
</html>
Share TDB SCHOOL
Share this E-Learning Website on social media platforms with your friends and followers