CSS Layout How to - Position fixed with floated element








Question

We would like to know how to position fixed with floated element.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div.wrapper {<!--from  w  w  w.j a  va2 s .  c o m-->
  width: 100%;
  height: 1000px;
  border: 2px solid #000000;
}

div.right {
  position: fixed;
  top: 10px;
  right: 0px;
  width: 200px;
  height: 100px;
  border: 1px solid #000000;
}
</style>
</head>
<body>
<body>
  <div class="wrapper">
    <div class="right"></div>
  </div>
</body>
</body>
</html>

The code above is rendered as follows: