Wednesday, April 25, 2012

Why does setting the `right` CSS attribute push an element to the left?

I have a very basic page with two elements, an outer green box, and inner blue box. I am confused as to why setting the right attribute on the inner box would move it to the left? Furthermore I am confused as to why right:0 would not align the boxes right edge to the right edge of the parent box? Here is my short example page...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<style type="text/css">
#outer {
background-color : green;
width : 500px;
height : 500px;

#inner {
position : relative;
background-color : blue;
height : 400px;
width : 400px;
top : 10px;
right : 20px;
<div id="outer">
<div id="inner">



No comments:

Post a Comment