Friday, September 23, 2011

Daily Question: How to set position of DIV?

I have been asked these questions and didn't always have an answer to them right away. I thought it would be interesting to document some of these so they may be helpful for you in the future. Note:The answer is in no way always the best/right, just my best attempt.

Here is first one: How to set position of DIV?

Answer: There are three position options in css,"absolute", "float" and "relative" Examples as below.

<style type="text/css">
.absolute {
 position: absolute;
 bottom: 50px;
 left: 100px;

  <div class="absolute">
  <p> in a div</p>

<div style="float: left; width: 50%; height: 100px;"></div>

<div class="background" style="position: relative; width: 728px; height: 200px;">

No comments:

Post a Comment