Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Dat
    Dat is offline
    Regular Coder
    Join Date
    Oct 2007
    Posts
    147
    Thanks
    28
    Thanked 0 Times in 0 Posts

    Why no align center

    It wont center? Why?

    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" xml:lang="en" lang="en">
    <head>
    <style type="text/css">
    body, html {
        font-family: Helvetica, Verdana, Arial, sans-serif;
        color:#565656;
        font-size: 12px;
    }
    
    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, font, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td {
        margin: 0;
        padding: 0;
        border: 0;
        outline: 0;
        font-size: 100%;
        vertical-align: baseline;
        background: transparent;
    }
    a {
        color: #EC0A8B;
        text-decoration: none;
    }
    a:hover {
    
        text-decoration: underline;
    
    }
    #wrap {
    }
    
    #content {
        float: left;
        margin-right: 5px;
        margin-left: 5px;
        margin-top: 30px;
        width: 980px;
        border-color: #dedfdd;
        border-width: 8px;
        border-style: solid;
    }
    
    #col-left {
        float: left;
    }
    
    #col-right {
        float: right;
    }
    
    #main-content {
        padding-right: 15px;
        background-color: #f9ff8a;
        margin-left: 15px;
        margin-top: 20px;
        width: 540px;
    }
    
    #main-content .featured {
        padding: 15px;
        width: 540px;
        color: #C4C4C4;
        background-color: black;
    }
    
    #main-content .featured h2 a {
        color:#FFFFFF;
        font-family:Georgia;
        font-size:19px;
        font-weight:normal;
        padding:10px 0 2px;
    }
    
    #main-content .featured p.post-details {
        margin-top: 5px;
        margin-bottom: 15px;
        padding-left: 17px;
        background:transparent url(images/post_details.gif) no-repeat scroll 0;
        font-size: 12px;
        font-style: italic;
        color: #787878;
    }
    
    #sidebar {
        background-color: #a2ff88;
        width: 400px;
    }
    
    .post {
    }
    
    .left {
        float: left;
    }
    
    .right {
        float: right;
    }
    
    #header, #wrap, #footer {
        margin:0 auto;
    }
    
    </style>
        </head>
        <body>
            <div id="wrap">
                <div id="content">
                    <div id="col-left">
                        <div id="main-content">
                            <div class="post wrap">
                                <div class="featured">
                                    <h2>
                                        <a href="#">Molestie innonummy Libero</a>
                                    </h2>
                                    <p class="post-details">
                                        by
                                        <a href="#">Dat</a>
                                        on 12/25/09
                                    </p>
                                    <a href="#"><img src="images/thumb.png"</a>
                                </div><!--End featured-->
                            </div><!--End post wrap-->
                        </div><!--End main-content-->
                    </div>
                    <div id="col-right">
                        <div id="sidebar">
                            dd
                        </div><!--End sidebar-->
                    </div><!--End col-right-->
                </div><!--End content-->
            </div><!--End warp-->
        </body>
    </html>
    Last edited by Dat; 11-04-2009 at 07:31 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    #content {
       /* float: left;*/
        margin-right: auto;
        margin-left: auto;
        margin-top: 30px;
    
        width: 980px;
        border-color: #dedfdd;
        border-width: 8px;
        border-style: solid;
    }
    btw, why do you need <div id="warp"> ? (hope you meant wrap there )
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Dat
    Dat is offline
    Regular Coder
    Join Date
    Oct 2007
    Posts
    147
    Thanks
    28
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Code:
    #content {
       /* float: left;*/
        margin-right: auto;
        margin-left: auto;
        margin-top: 30px;
    
        width: 980px;
        border-color: #dedfdd;
        border-width: 8px;
        border-style: solid;
    }
    btw, why do you need <div id="warp"> ? (hope you meant wrap there )
    Edit, but how do i make the wrap adjust to the middle. cause if i remove the float none of my contents stays inside the border.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by Dat View Post
    Edit, but how do i make the wrap adjust to the middle. cause if i remove the float none of my contents stays inside the border.
    You need to clear your floats and applying another float isn't the right way to do this.
    Try applying overflow:auto; to #content. See http://www.quirksmode.org/css/clearing.html
    (Or http://www.codingforums.com/showthre...640#post617640
    www.positioniseverything.net/easyclearing.html)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello Dat,
    In your CSS you have margin:0 auto; on #header, #wrap, #footer but that won't work until you set a width.
    Add a width to the wrap that's containing your site, like this -
    Code:
    #wrap {
    	width: 1006px;
    	margin: 0 auto;
    }
    Remove that float:left; like ab said, and replace it with overflow: auto; to clear your floats. Here's a site that explains how that works.
    Last edited by Excavator; 11-04-2009 at 07:55 AM.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •