Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Target Top Margin of Paragraphs on My Page

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #145066
    pittles78
    Participant

    Hi,

    On the page http://superluxefibers.com/services/ I want to bring the paragraphs closer to the images. I think that means a smaller margin.

    Not sure what the difference is between margin and padding btw.

    Can I assign a class to target just those

    ‘s on that page.

    Best,
    Jon

    #145068
    TheDoc
    Member

    In your particular case, you have a bottom margin on the image and a bottom padding on the paragraph.

    You’ll want to do two things:

    1. Remove the bottom margin from the image
    2. Change the padding-bottom on the

      to margin-bottom.

    To accomplish #1, find this in your CSS file and remove the margin:

    .row .col img {
        margin-bottom: 15px;
        max-width: 100%;
        width: auto;
        height: auto;
    }
    

    Think of padding as “inside” the element and margin as “outside”. The padding pushes the boundaries of an element (makes it bigger). So if you had a border around the element, or perhaps a background color, additional padding will make that element appear bigger.

    Margin, on the other hand, is on the outside of padding/border and pushes other elements further away.

    Here’s a really simplified example: http://codepen.io/ggilmore/pen/a3600b7fe3f3fcb2e00191f4c1cfd4d6

    #145070
    pittles78
    Participant

    Great explanation of padding vs. margin thank you.

    Ok, so I took care of the bottom margin, but in the html of my wordpress page I don’t see the

    tag on my image. I do see it when I look at the code in Firebug.

    Is WordPress placing

    <

    p> tags on all images? How can I make that not happen on this page?

    #145115
    Martin Duran
    Participant

    Yes, WordPress encloses images within p tags. In your example, the paragraph tag directly follows the h3 tags, and so there is a selector, one that is supports all the way down to ie7, for such an instance.

    Add the following to your css, and notice that it removes the padding bellow your images:

    h3 + P {
      padding: 0
    }
    
    #145117
    pittles78
    Participant

    Worked like a charm! Thanks again Martin.

    #145118
    Martin Duran
    Participant

    pittles,

    Be cautious, however, as that selector will remove the padding from any paragraph tag that follows an h3 tag.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.