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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2007
    Location
    Glencoe, Ontario, Canada
    Posts
    340
    Thanks
    19
    Thanked 27 Times in 27 Posts

    double border problemo

    Ok this is what I wanna do I wanna have a border on the container thats 8px of blue then a 1px outside the blue one that is black. but when i add the black one it does a full page pixel and when i try to make it the size of the container it off sets the container to the left.

    Code:
    #border { width:900px; border: #000 solid 1px;}	
    #container {
    	width:900px;
    	margin: 0 auto;
    	padding:14px;
    	background:#fff;
    	overflow: hidden;
    	border: #24456a solid 8px;
    	}
    www.ospunho.com
    Eric "PitbullMean" Melo
    Always Start your layout with*{border:0; margin:0; padding:0;}
    Be sure to Thank ALL Users who give assistance.

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    It would be probably be simplest to assign the width to the body, then any borders will be subtracted from that width, so with 900px you would have 882px left for the content.

    This is the proper order for the border properties:

    border:5px solid red;

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,667
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello PitbullMean,
    To center your site you need to apply width and margin:0 auto; to the containing div... in this case, #border. Centering #container inside border doesn't do much since they are the same width.

    Watch you don't mess up your box model doing this. The box model says that margin/padding/border all count when figuring total width.

    See my example:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {background: #FC6;}
    #border {
    	width: 944px;
    	margin: 0 auto;
    	border: 1px solid #000;
    }	
    #container {
    	width: 900px;
    	padding: 14px;
    	background: #fff;
    	border: 8px solid #24456a;
    }
    </style>
    </head>
    <body>
    	<div id="border">
            <div id="container">
            	some stuff here
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
            	some stuff here
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
            	some stuff here
            <!--end container--></div>
        <!--end border--></div>
    </body>
    </html>
    The extra 44px on #border is to make up for your border and padding on #container.
    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

  • Users who have thanked Excavator for this post:

    PitbullMean (11-22-2010)


  •  

    Posting Permissions

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