SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Quick CSS Question on Positioning

  1. #1
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Quick CSS Question on Positioning

    I have a table cell with a style that applies a background image. I put text in the cell and I want to use CSS to pad the text on the left side. But whenever I use padding-left:10px on the cell, even though there is plenty of room, it throws the image out of wack. How can I position the text without messing up the image?

    Here is the page where this is happening:
    http://www.rantous.com/rantous

    Thanks
    Last edited by optl; Jul 3, 2007 at 09:38.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,468
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hardly ever mess with tables and CSS, but you might want to look into collapsing your tables, then adding a DIV or SPAN to your TD as a child, then applying the text to the DIV (or SPAN).

    Just bear in mind that SPANs cannot contain block-level elements (such as DIV or P) and that P cannot contain a DIV (or other block-level element), and you should be fine.

  3. #3
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I collapse my table?
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  4. #4
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,468
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    table {
    	border-collapse: collapse;
    }
    The short story is that this will get tables working consistently cross-browser without having to worry about any issues with cellpadding and cellspacing (not to mention borders). Or at least that's what I understand anyway. Like I said, I hardly ever deal with tables anymore (even data tables).

  5. #5
    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)
    To be honest it doesn't sound like you're doing anything wrong. A background image should still show behind your padding so without seeing the HTML/CSS or a link to the problem it'll be difficult to see what the problem is.

    Dan's solution may solve your problem as without collapsing the border it'll appear as though you've got margins around all your cells but I think you're probably experiencing something different, maybe caused by something else in the CSS.

  6. #6
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I uploaded the code for you guys:
    http://www.rantous.com/rantous
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  7. #7
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any thoughts? Padding is pushing the text as well as the background image. I just want it to push the text.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  8. #8
    padawan silver trophy
    SitePoint Award Recipient markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,014
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    padding does not effect positioning of the background image on an element.
    It effects the width of an element so that might be why the background image is moving,

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
  •