SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Padding? Question

    Question is: How do I get the space between the tops of the words and the boxes to disappear?


    <!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" xml:lang="en">

    <head>
    <title>Example 5: Negative Margins</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

    <style type="text/css" media="screen">
    /*<![CDATA[*/
    body{
    margin:0;
    text-align:center;
    background-color: #000000
    }
    #outside{
    position:relative;
    width:96%;
    text-align:center;
    margin:4% auto 82px;
    background-color:#00ff00;
    }
    #header {
    border: 1px solid #cecea5;
    background: #d7dabd;
    }
    #outer_wrapper {
    background: #fff url(background_3.gif) repeat-y left;
    }
    #wrapper {
    background: url(background_2.gif) repeat-y right;
    }

    #container {
    width: 100%;
    text-align:left;
    float: left;
    margin-right: -200px;
    background: url(background_2.gif) repeat-y right;

    }
    #content {
    margin-right: 200px;
    background: url(background_3.gif) repeat-y left;
    }
    #main {
    margin-left: 150px;
    }
    #left {
    width: 150px;
    float: left;
    }
    #sidebar {
    width: 200px;
    float: right;
    }
    #footer {
    border: 1px solid #cecea5;
    background: #d7dabd;
    }
    h1 {
    margin-top: 0;
    }
    .last {
    margin-bottom: 0;
    }
    .clearing {
    height: 0;
    clear: both;
    }
    .centered {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -25%;
    margin-left: -25%;
    background-color: red;
    color: white;
    }
    /*]]>*/
    </style>
    </head>

    <body>
    <div id="outside">
    <div id="header">header</div>

    <div id="outer_wrapper">

    <div id="wrapper">
    <div id="container">
    <div id="content">

    <div id="left">
    <h1>navbar</h1>
    <ul>
    <li>link one</li>

    <li>link two</li>

    </ul>
    </div>

    <div id="main">
    <h1>content</h1>
    <p>some content</p>

    <p class="last">shrug</p>
    <p>some content</p>
    <p class="last">shrug</p>
    <p>some content</p>
    <p class="last">shrug</p>

    <p class="last">shrug</p>

    </div>


    </div>
    </div>

    <div id="sidebar">
    <p>side zomgdesire.</p>
    </div>


    <div class="clearing">&nbsp;</div>
    </div>

    </div>

    <div id="footer">footer</div>
    </div>

    </body>
    </html>

  2. #2
    SitePoint Wizard bronze trophy DaveWoods's Avatar
    Join Date
    Dec 2004
    Location
    Derbyshire - UK
    Posts
    2,651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easiest way would be to use the global reset at the top of your CSS

    Code:
    * { padding: 0; margin: 0; }
    Or alternatively set each elements, padding and margin to to what you want instead of relying on the browsers default.

  3. #3
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've found myself using this a lot lately rather than the universal reset (it basically does the same thing, but leaves form controls alone - and yes, I intentionally included the inline elements as well).

    Code CSS:
    html, body, address, blockquote, div, dl, form, h1, h2, h3, h4, h5, h6, ol, p, pre, table, ul,
    dd, dt, li, tbody, td, tfoot, th, thead, tr, button, del, ins, map, object,
    a, abbr, acronym, b, bdo, big, br, cite, code, dfn, em, i, img, kbd, q, samp, small, span,
    strong, sub, sup, textarea, tt, var {
    	margin: 0;
    	padding: 0;
    }

  4. #4
    SitePoint Wizard bronze trophy DaveWoods's Avatar
    Join Date
    Dec 2004
    Location
    Derbyshire - UK
    Posts
    2,651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah Dan, I tend to use something like that if I'm dealing with forms but as the original post didn't have any, I don't see any harm with using the global selector.

    In fact there's only a few elements used so something like this would also do the job.

    Code:
    body, p, ul, li, div, h1 {
      margin: 0; 
      padding: 0;
    }

  5. #5
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, a lot of the sites I've been working on lately have floated search forms (with everything on one line) and I've found this to be better than hacking for IE 6/7 (or using conditional comments to deliver a separate stylesheet to IE 7) - and don't get me started with the way Firefox renders form controls either since I'd probably get banned for what I'd say about it.

    Otherwise I'd agree with you 100&#37;.


Bookmarks

Posting Permissions

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