Kundan Kumar
35
Q:

html position div

The position property specifies the type of positioning method used for an element (static, relative, fixed, absolute or sticky).

The position Property:
----------------------------
The position property specifies the type of positioning method used for an element.
There are five different position values:
  1. static
  2. relative
  3. fixed
  4. absolute
  5. sticky
Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the position value.

position: relative;
-----------------------
An element with position: relative; is positioned relative to its normal position.
Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element.

Suppose a <div> element has position: relative;
Here is the CSS that is used:

Example:
div.relative {
  position: relative;
  left: 30px;
  border: 3px solid #73AD21;
}
15
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test</title>
<style>
  #foo {
    position: fixed;
    bottom: 0;
    right: 0;
  }
</style>
</head>
<body>
  <div id="foo">Hello World</div>
</body>
</html>
1
#IMAGE_ID {
	position:absolute;
  
  	/*left: (how much pixles from the left you want)px*/
  	left:100px;
  
    /*top: (how much pixles from the top you want)px*/
  	top:100px;
}

#MY_OTHER_IMAGES_ID {
    /*right: (how much pixles from the right you want)px*/
  	right:100px;
  
    /*bottom: (how much pixles from the bottom you want)px*/
  	bottom:100px;
}
2

position: static|absolute|fixed|relative|sticky|initial|inherit;
3
<!DOCKTYPE html> <!-- Start of coding page -->
<html> <!-- Start of html coding -->
  <head> <!-- Start of head -->
    <title>TITLE<title> <!-- Title -->
    <script>
      //JavaScript
    </script>
    <style>
      /* CSS */
    </style>
  </head> <!-- End of head -->
  <body> <!-- Start of body -->
    <div id='mydiv' style = "position:relative; left:0px; top:100px;">
      Hello! 
      <!-- Use that style tag to positions things, have a play around with it! -->
    </div>
  </body> <!-- End of body -->
<html> <!-- End of html coding -->
<!-- Add this line of code next to your id: 

style = "position:relative; left:0px; top:100px;" 

too let you position divs where you want them, you can even position
them ontop of other divs! -->
1

New to Communities?

Join the community