Relative position to the right and top : position relative « Layout « HTML / CSS






Relative position to the right and top

 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title></title>
  <style type="text/css">
body {
  margin: 0px;
  padding: 0px;
  color: #000;
  background-color: #ccc;
}


.myStyle {
  position: static;
  padding: 10px;
  margin: 5px;
  background-color: #fff;
  border: 1px solid #000;
  width: 20%;
}

.different {
  position: absolute;
  top: 25px;
  right: 25px;
  padding: 10px;
  margin: 5px;
  background-color: #fff;
  border: 1px solid #000;
  width: 20%;
}


  </style>
</head>


<body>
  <div class="different">1</div>
  <div class="myStyle">2</div>
  <div class="myStyle">3</div>
  <div class="myStyle">4</div>
</body>


</html>

 








Related examples in the same category

1.position:relative positions an element at an offset from its location in the normal flow.
2.Using Relative Positioning
3.relative position to the bottom and left
4.position relative: top left
5.position relative and absolute
6.Centre an element of no specified width
7.Relative positioning of elements
8.Relative positioning uses left, top, and z-index to control the offset of the box.
9.Control the stacking order of a float or an element in the normal flow.
10.relative positioning
11.This element is offset from its original position.
12.element is positioned to the bottom left of the relatively positioned element.
13.Element is positioned to the bottom right of the relatively positioned element.
14.This element is positioned to the top right of the relatively positioned element.
15.This element is positioned to the top left of the relatively positioned element.