Horizontally Stretched Absolute : Box Layout « Style Basics « HTML / CSS






Horizontally Stretched Absolute

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css" media="Screen">
* .grandContainer {
  position: relative;
  z-index: 10;
  background: red;
}

#hsa {
  position: absolute;
  width: auto;
  left: 0;
  margin-left: -30px;
  right: 0;
  margin-right: -30px;
  height: auto;
  top: auto;
  margin-top: 30px;
  bottom: auto;
  margin-bottom: auto;
  background: gold;
}

</style>
</head>
<body>
<div class="grandContainer">Positioned Grandparent 
  <div class="parent">Non-positioned Parent 
    <span id="hsa" class="s">Horizontally Stretched Absolute</span> 

  </div> 
</div> 
</body>
</html>

 








Related examples in the same category

1.Horizontally Stretched Static
2.Vertically Stretched Absolute
3.Indent the left and right sides of a static element
4.Move right and left with margin
5.Indent up and down with margin
6.Parent position: absolute, child position fixed or absolute
7.Parent position: relative, child position fixed or absolute
8.Parent position: absolute, child position: relative or static
9.Offset Absolute and Offset Fixed
10.Sized Block Outside to the Left of its parent
11.Sized Block Outside to the Right of its parent
12.Sized Float Outside Left to its parent
13.Sized Float Outside to the Right of its parent
14.Positioned parent and non-position child
15.Sized Absolute
16.Sized relative
17.Shrinkwrapped Absolute
18.Shrinkwrapped Relative
19.Static container and absolute child to top and left
20.Static postioned container and absolute child to the top and right
21.Static positioned container with child to the bottom and left
22.Static positioned container with child to the bottom and right
23.Relative positioned container with absolute positioned child to the top and left
24.Relative positioned container with absolute positioned child to the top and right
25.Relative positioned container with absolute positioned child to the bottom and left
26.Relative positioned container with absolute positioned child to the bottom and right