Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #595799

    I want to reduce margin-top from 50px to 0px for a Special Heading.

    If I add this to my child theme then it works for the whole site.

    .av-special-heading {
    	margin-top: 0px;
    }

    However, I have set a Custom CSS class of ‘retweets’ on a Special Heading element on the home page so that I just target one specific heading, but using this code

    .retweets .av-special-heading {
    	margin-top: 0px;
    }

    does not work, the custom class is ignored and the margin-top returns to 50px.

    You can see the CSS class on this screenshot.
    Screenshot

    You can see the page here dev.henleyherald.com, it’s the Latest Retweets heading in the right column.

    Any idea why it’s not working?

    • This topic was modified 8 years, 8 months ago by zimbo.
    #595918

    Hey zimbo!

    Do you mind creating a temporary admin login and posting it here privately? I cannot see custom class on your element

    Best regards,
    Yigit

    #596310

    Details in private content, it’s a development/test site so not everything is working yet. :-)

    #596370

    Hi!

    I changed your code to following one

    .retweets {
    	margin-top: 0px;
    }

    Please review your website now

    Best regards,
    Yigit

    #596383

    Thanks Yigit, looks OK now.

    For future reference / my education… can you explain why it doesn’t need the .av-special-heading class adding? I think I maybe misunderstand how the Custom CSS Class works – I use it in some places and I have to specify an additional class to target an element, yet in other places I don’t. Just trying to save posting future support questions if I can!

    #596389

    Hi!

    Please see this screenshot – http://i.imgur.com/MOPeMo1.png
    As you can see “retweets” and “av-special-heading” are classes of the same element. You can target it correctly as following as well

    .retweets.av-special-heading { margin-top: 0; }

    But since targeting “retweets” would be enough, you do not need to add “av-special-heading” :)

    Let us know if you have any other questions!

    Cheers!
    Yigit

    #596891

    @Yigit: well, you live and learn… :-)

    I’d seen classes used without a space in previous answers here but didn’t understand why before.

    Are there any rules as to when I’d need to specify a theme element like .av-special-heading as well as the Custom Class or is it dependent on the HTML element and what CSS property I’m trying to add or modify and so just a matter of trial and error until something works?

    #596896

    Hi!

    For specific elements with custom classes, you would not need. Only if you would like to target globally. If your custom code does not apply, then you can use !important rule as following

    .retweets img { margin-top: 0 !important; }

    Cheers!
    Yigit

    #596972

    Thanks Yigit, very helpful – case closed!

    #597332

    Hi,

    Great, glad we could help :-)

    Regards,
    Rikard

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.