• When I add a sidebar widget on my page, why does it have a margin and indent. How can I get this widget to align with the rest of my text to the left?

Viewing 7 replies - 1 through 7 (of 7 total)
  • When I add a sidebar widget on my page, why does it have a margin and indent.

    The appearance of your WordPress site is controlled by your theme. So either your theme developer intended it this way, or (more likely) a global style defined in your theme for list indenting in articles is being applied to the sidebar as well.

    How can I get this widget to align with the rest of my text to the left?

    As this is defined by your particular theme and not WordPress itself? there’s no universal way code or something that can fix this.

    If you can give us your website, we can check and give you CSS code to overwrite your theme’s style.

    Good luck!

    Thread Starter joyeeyap

    (@joyeeyap)

    Hi George,

    Here is an example: https://sites.uw.edu/joyeeyap

    I would love to obtain a CSS code that aligns the widget to the text, all aligned to the left. Thank you so much for your help!

    Hello,

    This code is what is shifting your widgets to the RIGHT, as seen in the screenshots below for both the main content and sidebar areas:

    .widget {
        padding: 10px 0 0 40px;
    }

    The padding numbers above follow a clockwise pattern starting from the top, ie: TOP RIGHT BOTTOM LEFT. So there’s left padding of 40px and right padding of 0, hence the shift to the right.

    To fix this, all you have to do is place this CSS code in the ADDITIONAL CSS box at APPEARANCE => CUSTOMIZE (or wherever you maintain your custom CSS)… making sure to change the left margin value from 40px to zero, ie:

    .widget {
        padding: 10px 0 0 0;
    }

    I hope that helps!

    Hello Again!

    I just noticed the note “I would like to align this to the left” on your test page. The CSS code I gave above only takes care of the outer indenting, and not the inner one.

    To be clear, after taking care of the outer left padding above, the card layout should look OK in the small sidebar column where (I believe) these widgets were intended to be used.

    But as you’re using the widgets in the larger main content area, these paddings become larger because they are defined as percentages of the parent container, and not as absolute amounts. Thus additional work has to be done to reduce these paddings.

    And, once again, to address this issue, we have to undo some CSS styles defined in your theme for the card.

    And this is perhaps the time to pause for a moment and consider whether it’ll be easier and even better to get in touch with the developer of the custom theme you’re using to address this, to avoid any unintended effects should you go ahead with the suggested changes below.

    Still, want to fix this yourself? Let’s give this a shot then:

    First, the card has padding: 10% 14% 5% 14%, which squishes everything away from the left and right.

    Now since this is defined on the entire card, you’d expect the image to also be indented as well, just like the text. Well, except the image has been given a width of 139% to compensate for the padding, as well as a bunch of negative margins… as seen below:

    So to fix this, we’ll first have to reduce the left and right paddings on the entire card. In the CSS code below, I’ve changed the left and right paddings from 14% to just 2%, leaving the top and bottom paddings unchanged.

    .cards-widget .default-card {
    padding: 10% 2% 5% 2%; 
    }

    That takes care of the text problem. But as you can see below, the images are now extending beyond the card container. That’s because of the width of 139% and negative margins I mention earlier.

    After playing around with the width and margin numbers, here’s what seems to work:

    .cards-widget .default-card .card-image {
    width: 104%;
    margin: -13.5% -2.5% 0 -2%;
    }

    PLEASE NOTE:

    Kindly note that I could only test this on the specific page you gave and without reloading the page… as I don’t have access to your site to make this code persist when the page is reloaded or when I navigate to another page. It’s possible (though not likely) that the above CSS changes could break something elsewhere in the site.

    Unfortunately, I have no way of knowing or testing this.

    This is why I mentioned from the onset that you should probably get in touch with the developer of this theme (if you can) to get their input.

    Good luck!

    Thread Starter joyeeyap

    (@joyeeyap)

    Wow thank you so much George! This was so helpful, I am very grateful for your help!

    Thread Starter joyeeyap

    (@joyeeyap)

    Would you also happen to know why the text of my widget for this style of card does not show up?
    https://sites.uw.edu/joyeeyap/
    Is my text behind the image?

    Sorry, I’m travelling now and very, very busy.

    Is my text behind the image?

    Yeah, the text is definitely behind the image.

    Below you can see the text on the page after I disable the image.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Widget Indent’ is closed to new replies.