How exactly does CSS positioning work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AaronL
    New Member
    • Jan 2007
    • 99

    How exactly does CSS positioning work?

    Hello everyone,

    I'm new at CSS and basically I want to create elements within elements with the proper positioning, this page I'm working on looks the way I want it to, but I think the CSS is wrong. For instance the text "This is content" is centered and I want that to be aligned to the left and only certain things centered. Next thing is I want to have the page start with a defined height, however as the content grows, I would like the left right and middle columns to all grow at the same time with the content, can you do that in CSS? Here is the URL: http://www.ecommphppro.com/rukusradio

    Here is the CSS:
    Code:
    body {
      position:relative; 
      background-color:#000000; 
      margin-top:0px; 
      margin-left:0px;
    }
    
    #container {
      position:relative; 
      width:1024px; 
      margin-left:auto; 
      margin-right:auto; 
      margin-top:0px;
    }
    
    #header {
      position:relative; 
      width:1024px; 
      height:180px; 
      background:#000000; 
      background-image:url('images/headerbkg.jpg'); 
      background-repeat:no-repeat; 
      background-position:top left;
    }
    
    #rukus3dlogo {
      position:relative; 
      z-index:9999; 
      left:0px; 
      top:0px;
    }
    
    #rukuslogo {
      position:relative;
      z-index:9999; 
      left:700px; 
      height:180px; 
      top:-225px; 
      background-color:#000000;
    }
    
    #leftcolumn {
      float:left; 
      width:271px; 
      height:1280px; 
      background-color:#000000; 
      background-image:url('images/sidebkg.jpg'); 
      background-repeat:repeat-x;
    }
    
    #middlecolumn {
      position:relative;
      text-align:left;
      z-index:1; 
      background-color:#ffffff; 
      left:190px; 
      width:650px; 
      height:1280px;
    }
    
    #rightcolumn {
      z-index:0; 
      position:relative; 
      float:right;
      top:-1280px; 
      width:271px; 
      height:1280px; 
      background-color:#000000; 
      background-image:url('images/sidebkg.jpg'); 
      background-repeat:repeat-x; 
    }
    
    #menubar {
      z-index:2; 
      width:1024px; 
      height:50px; 
      background-image:url('images/mnubarbkg.jpg'); 
      background-repeat:repeat-x; 
      box-shadow:5px; 5px; 5px; #000000;
    }
    Here is the HTML code:
    Code:
    <!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>
      <link rel="stylesheet" type="text/css" href="style.css" />
      <title></title>
      </head>
      <body>
        <div id="container">
          <div id="header">
            
            <div id="rukus3dlogo">
              <img src="images/rukus3dlogo.png">
            </div>
            
            <div id="rukuslogo">
              <img src="images/rukuslogo.jpg">
            </div>
                  
          </div>
          
          <div id="menubar">
          </div>
          
          <div id="leftcolumn">
          </div>
          
          <div id="middlecolumn">
            This is content
          </div>
          
          <div id="rightcolumn">
          </div>    
          
        </div>
      </body>
    I don't know if I'm over thinking things but it appears that I really don't understand positioning
  • AaronL
    New Member
    • Jan 2007
    • 99

    #2
    I also tried to put an image in the middle column and it stuck it all the way at the bottom of the page

    Comment

    • AaronL
      New Member
      • Jan 2007
      • 99

      #3
      Well I stole a layout to get it to work but I still don't really understand, I had to set the position to absolute on the click to listen button on that page and it moves around when you minimize the browser window and I don't want that :(

      Comment

      Working...