Forums

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

Home Forums CSS How to handle number 'objects'

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #189658
    misscosmic
    Participant

    I want to make a padding around all the images used in a WordPress site.
    <div id="attachment_98" class="wp-caption alignleft" style="width: 510px">
    <code></code>

    So I want to define padding for all the ‘attachment_anynumber’. How do I do this?

    Peace and happiness

    #189665
    Paulie_D
    Member

    It’s not quite clear to me what you are trying to do as the code you have provided doesn’t seem to relate to images…certainly I can’t see any reference to one.

    However, if you want to add padding to any div with an id starting with attachment_ you can do this

    
    div[id^="attachment_"] {
    padding: whatever;
    }
    

    or if padding around images inside such divs

    
    div[id^="attachment_"] img {
    padding: whatever;
    }
    

    http://code.tutsplus.com/tutorials/the-30-css-selectors-you-must-memorize–net-16048

    #189668
    misscosmic
    Participant

    Thanks Paulie_D for getting back with the speed of light (-:

    Maybe it is easier when I paste the whole code. Like I siad I would like to give padding to all the images used which as far as I can see are called attachment_number

    
    <div class="wp-caption alignleft" style="width: 510px" id="attachment_98">
    <img width="500" height="328" alt="Project de renovation" src="http://localhost/eric_merlier/wp-content/uploads/2014/12/image_01.jpg" class="size-full wp-image-98">
    <p class="wp-caption-text">Project de renovation</p>
    </div>
    
    #189674
    Paulie_D
    Member

    Not quite…the images are inside divs with an ID of attachment-xx.

    So if you are adding padding around the image self (and only the image) then the second example I gave should work.

    This assumes that all the images you want to target get put inside divs with that kind of ID reference / name.

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