Support » Themes and Templates » Ignore padding for images inside paragraph

  • This looks simple at first glance, but I couldn’t find a solution so far, after a lot of searching.
    I want to have different padding for images and text inside a div.
    The images are inserted in articles without uploader, from HTML, so they don’t have a class of their own such as float. WordPress sometimes puts that inside <p>paragraph</p>, other times it’s just the <img> without <p>.
    I can give attributes to “.entry_class img”, but that will inherit the properties of the paragraph. That is, the image can have some extra padding than the text, but not less. And I need the image to be exactly the size of the div, while the text still hass some nice padding around.
    I’ve tried overriding the div properties with “!important” for “img” but with no success. There must be a solution to style images inside the loop.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael


    Forum Moderator

    please post a link to your site to illustrate exactly what you mean.

    you can obviously try to style:

    .entry_class p img { ... }

    or whatever css allows you to do.

    Thank you for your reply. It’s a theme I’m trying to reshape now, so it’s not online. That’s also part of the problem as I have many articles already online, without classes specified for images, and would be impossible to change those. Here are the essentials.

    The HTML part:

    <div class="article">
    <p><?php the_content($more_link_text , $strip_teaser, $more_file );?></p>

    The CSS part:

    .article {
    .article p {
    .article img{

    I’ve tried different options, with or without <p> for the loop.

    I found something that helps on the vertical. Using a larger first letter also creates space between paragraph.

    .article p:first-letter{

    Still, this is of no help when you want really large padding on the sides and no padding for pictures :(.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Ignore padding for images inside paragraph’ is closed to new replies.