• HI folks.

    I’m going to be having quite a few editorial notes throughout the text passages on my site (Twenty Twelve child theme) and I want all such notes to have different font size, colour and line-height from the ‘normal’ text sections. Thus, I created a div class as follows:

    .ednotes {
    color:#0000FF;
    font-size: .9rem;
    line-height: 1.1rem;
    text-align: justify;
    }

    The styling is fine, but the editorial notes are appearing with a space at the top, and no space at the bottom (ie: the next paragraph begins immediately below). I want it the other way around.

    An example will show what I mean. Pls see this link:
    http://ppredesign.perthpunk.com/personal-perspectives/andrew-hassack/

    1. How do I eliminate the space between “…pop songs” and the editorial notes?

    2. How do I have normal paragraph spacing between the ed notes and the beginning of the next para (beginning “I recall The Scientists’ first gig…”)?

    I’ve tried all sorts of CSS I’ve found on the web, but can’t hit the jackpot. Would be most appreciative of any help.

    Cheers
    Ross

Viewing 14 replies - 1 through 14 (of 14 total)
  • I’m sorry but it is really beyond the scope of these forums to deal with general CSS issues. Try a dedicated CSS resource such as http://www.css-discuss.org/ instead. In the meantime, try using Firefox with the Firebug add-on for this kind of CSS work. Or use whatever developer tool is available in your web browser.
    http://getfirebug.com/

    Thread Starter RossB

    (@rossb)

    I thought it was a very specific issue I asked about. Don’t really understand what’s acceptable to ask here and what’s not, then. I’ve seen lots of questions like this one asked here – and answered. Including some of mine.

    Thing is, I thought this was a WordPress-specific question, because I’ve copied my current code into Stackoverflow’s ‘TryIt’ editor and can get it to look how I want there. Yet, the same code doesn’t work in my Twenty-Twelve child theme. I would have stated this, but didn’t think there was a need.

    But whatever you say I guess, esmi.

    Thanks.
    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    A CSS issue inside WordPress is the same as a CSS issue outside WordPress. It’s just CSS.

    When we answer CSS queries, all we’re doing is using a browser developer tool like Firebug (which Esmi recommended) to determine the solution. Firebug will tell you the styling applied to the paragraph; helping you understand what you need to override to change it.

    Thread Starter RossB

    (@rossb)

    Yes, I’ve been squinting at Firebug until I’m blue in the face. Can’t figure out what code to change or how to change it. That’s why I resorted to asking about it here. I always TRY to research things and try out everything I can before posting here.

    So ta Andrew, but been there, done that, and to no avail.

    And I still don’t get why this CSS question is “beyond the scope of these forums to deal with”, yet there are many, many CSS issues posted here that are addressed, and are therefore apparently within the scope of these forums. Beats me how to discern which is which. All very, erm, ‘nuanced’ it seems to me.

    Cheers
    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    And I still don’t get why this CSS question is “beyond the scope of these forums to deal with”, yet there are many, many CSS issues posted here that are addressed, and are therefore apparently within the scope of these forums.

    I don’t get it neither. I used to say that it was beyond the scope of these forums to deal with CSS issues as well, but then I was told that it’s within the scope these forums by other mods.

    Beats me how to discern which is which. All very, erm, ‘nuanced’ it seems to me.

    Doesn’t matter much, if someone wants to help they can. It’s only if a theme is released under a license other than GPL that those people are really denied support.

    Back to your issue,
    Are you familiar with CSS nth-child?

    Thread Starter RossB

    (@rossb)

    Yep, a lot seems to depend on the mod. That was sorta my sub-text 😉

    And as you say, Andrew, help may well come anyway, depending on who’s around. I’ve had some terrific CSS and other assistance here from very generous and willing parties, including you.

    No, I haven’t heard of CSS nth-child. I assume, since you mention it, that it’s relevant to the space problem I’m having…but…

    Eyes falling out now, and need some zzedz, so will return fresh and hopeful tomorrow.

    Cheers!
    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You need to target the paragraph before the editorial notes and remove its bottom margin.

    To target that paragraph, you could manually add a class to it and then target that, use CSS nth-child to target the 5th paragraph or use jQuery to target it.

    Applying the class to the paragraph through the ‘text’ tab on your post/ page will be alright as long as you don’t accidentally remove it.
    Then you could target that class in the CSS:

    .entry-content p.className {
     margin-bottom: 0;
    }

    Applying CSS nth-child is alright if you’re not going to change the amount of paragraphs:

    .entry-content p:nth-child(5) {
     margin-bottom: 0;
    }

    Applying jQuery would be the safest option because it could target the paragraph before the editorial notes, regardless which paragraph it is:

    jQuery(document).ready(function($){
    
     $('.ednotes').prev().css('marginBottom', '0');
    
    });

    With Jquery you’ll need to first enqueue it using the methods discussed in this article: http://codex.wordpress.org/Function_Reference/wp_enqueue_script .

    How do I have normal paragraph spacing between the ed notes and the beginning of the next para (beginning “I recall The Scientists’ first gig…”)

    You can give the editorial notes a margin bottom by just using CSS:

    .ednotes {
     margin-bottom: 24px;
    }

    Thread Starter RossB

    (@rossb)

    Andrew, just a quick one initially to acknowledge you for the effort you’ve obviously put into your response above. I can’t get to the computer to try out your recommendations until later today, but am looking very forward to then.

    I can see by perusing your post that I would never have figured this out by myself, no matter how much researching and googling I did – understanding and/or applying things like Jquery is just beyond me at this point.

    So, indebted to you. Thanks a lot.

    Cheers
    Ross

    Thread Starter RossB

    (@rossb)

    OK, back with the glad news that I’ve managed to position the editorial note just as I wanted it. I ended up deviating slightly from my initial intention to have the notes appear immediately under the preceding para, deciding after experimenting that a bit more of a gap looked better.

    I have you to thank, Andrew, for setting me on the track I ended up taking. It was your last bit of code, showing how to give the ed notes a margin bottom, that opened the way forward for me. From there, I arrived at the following, which gave me the look I decided was best:

    .ednotes {
    color:#0000FF;
    font-size: .8rem;
    line-height: 1.1rem;
    text-align: justify;
    margin-bottom: 14px;
    margin-top: -24px;
    width: 90%;
    padding: 10px;
    }

    I feel that I’ve shirked the hard work, since I got where I wanted without learning to apply Jquery or CSS nth-child, but rest assured, I’ve copied your solutions to a file I’m compiling for future reference.

    Just one thing. Would be interested in any feedback on the code I finally applied. I know nothing about the fundamentals of good CSS practice. Is my solution OK? I know it’s simple, and it works, but are there aspects to it that are inelegant and a no-no in the context of CSS best practice? Keen to learn to do things the “right” way.

    Cheers and thanks again!
    Ross

    Thread Starter RossB

    (@rossb)

    Ha – found something that raises a question. When the page is narrowed as it would be when viewed on a cellphone, the ednotes styling disappears and it reverts to default text.

    I tried prefacing the ednotes code with @media screen and (min-width: 600px) {

    Just a wild guess, and not a good one – didn’t make any difference. Would be interested in an explanation, and in remedying this defaulting to standard text when site is narrowed beyond a certain amount…?

    Cheers
    R

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Would be interested in any feedback on the code I finally applied. I know nothing about the fundamentals of good CSS practice. Is my solution OK?

    It works, but there are 2 issues that I can see with it.
    1. It doesn’t address the underlying issue.
    2. Minus margins format differently on different browsers.

    You can address concern no.2 by instead using CSS positioning. Positioning is more reliant across browsers than margin.

    You’d just replace the margin-top property with top and add position: relative;

    top: -24px;
    position: relative;

    When the page is narrowed as it would be when viewed on a cellphone, the ednotes styling disappears and it reverts to default text.

    I think that’s because that style is within a media query.

    I tried prefacing the ednotes code with @media screen and (min-width: 600px) {

    All of the styles within that media query only apply when the browser is at a width of 600px or higher. So it won’t apply to 480px (standard mobile phone size).

    You need to close off that media query and then put the styles below it, e.g:

    }
    
    .ednotes {
      color:#0000FF;
      font-size: .8rem;
      line-height: 1.1rem;
      text-align: justify;
    
      width: 95%;
      padding: 10px;
    
      top: -24px;
      position: relative;
      margin-bottom: 14px;
    }

    Thread Starter RossB

    (@rossb)

    Your recommended code has fixed the defaulting to standard text issue, Andrew – great! Thank you. You’ve taught me a lot just in this exchange.

    If you don’t mind, 2 more questions, pls.

    1. Which types of styling should go above the media query close-off, and which should come after – other than .ednotes, obviously? Is there any sort of general rule I should apply from now on?

    2. Since it’s better to change
    margin-top: -24px;
    to
    top: -24px;
    position: relative;

    does it follow that it would also be better to change
    margin-bottom: 14px;
    to
    bottom: 14px
    position: relative;
    ?

    Cheers!
    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    1. Which types of styling should go above the media query close-off, and which should come after – other than .ednotes, obviously? Is there any sort of general rule I should apply from now on?

    That’s up to you. If you find a style should be applying to the mobile but isn’t, then remove it from that media query.

    does it follow that it would also be better to change
    margin-bottom: 14px;
    to
    bottom: 14px

    CSS positioning moves elements. Since your bottom margin is not moving the editorial notes, it should not be converted to a position.

    Thread Starter RossB

    (@rossb)

    OK, thanks Andrew (an aha moment for me re your response to query 2 – excellent).

    Best,
    Ross

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

The topic ‘eliminate space above div class’ is closed to new replies.