CSS problem

Discussion in 'Software' started by brauchi, Aug 14, 2004.

  1. brauchi

    brauchi Private E-2

    I am new to CSS and I am running into a problem. Does anybody know why I can't get the columns aligned the right way.

    In the CSS file I have the two columns assigned as followed:

    #content {

    margin: 0 0 0 121px;
    width: 510px;
    }

    #sidebar {
    position: relative;
    font-size: 90%;
    line-height: 1.5em;
    margin: 0 0 0 630px;
    padding: 60px 15px 0 20px;
    color: #937966;
    }

    I would like to have content appear within a width of 510px starting at 121. The sidebar should appear starting on pixel 630. That second part seems to work by itself. But as soon as I change the setting for id=content the sidebar stuff no longer is in the right position. Does anybody know what I am doing wrong?

    <div id="main-body">

    <div id="content">

    here comes some simple text to see where we are going with this.here comes some simple text to see where we are going with this.</div>



    <div id="sidebar">

    just some small text to see how this works.</div>
    </div>
     
  2. goldfish

    goldfish Lt. Sushi.DC

    Well, for a start, you can't put a div inside a div. And why are you using divs? Surley a table would work much better for this kinda thing?
     
  3. goldfish

    goldfish Lt. Sushi.DC

    Heres a snippet that would achive what it looks like youre doing, plus a little more.
    Code:
    <style>
    #sidebar { width:200px; }
    #content { font-family:Verdana, Tahoma, sans-serif;font-size:8pt; }
    </style>
    <table>
    <tr><td colspan="2">Titlebar</td></tr>
    <tr><td>Sidebar navi</td><td id="content">Some content goes here</td></tr>
    </table>
    
    In that sidebar cell, you can put a div which you can move around and position where you like :)
     
  4. Love2000AMGlam

    Love2000AMGlam Private E-2

    I'd just like to point out that you can have a div in a div, but tables probably would work better in this case. :)
     
  5. goldfish

    goldfish Lt. Sushi.DC

    Its not very well supported, and javascript goes crazy if you do it. In any case, divs are not good for layout :)
     
  6. Kodo

    Kodo SNATCHSQUATCH

    It's hard to do div layouts, but I agree, you can have div in div. BUT, rolling back to using CSS with tables when you want to loop is the better solution. Most of my new projects use 70%CSS with 30% tables. Opera is the only one that gives me a hard time with CSS. FireFox and IE work fine though IE has it's little CSS quirks.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds