You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just wondered if you might implement something like this, since having body classes for the last block on the page/post/whatever can be quite helpful (for setting bottom padding on the content area, for example).
The text was updated successfully, but these errors were encountered:
So, my use case is that on many of my sites I'm building using atomic blocks for some basic layout elements – so if the final block within .entry-content is a full-width ab-container, then I'll want .entry-content to have no margin on the bottom. However, if the last child is a paragraph or list or image, then I'll want a default margin to apply.
The :last classes actually don't apply very consistently here regardless. For example, when logged into the site, the edit page/post link is actually the last element, but when logged out, the final block is the last element. There are other situations that can crop up as well, where (for example) I've seen that sometimes comments with trackback information are injected after the last element of the .entry-content area, which I believe can affect usage of the :last pseudoelements (not sure where that's coming from, but you can see an example if you inspect this blog post: https://elod.in/contextual-styling-in-the-gutenberg-editor/)
The styling would be done more cleanly if a body class let me target the .entry-content directly.
This is my probably pretty clunky solution for outputting as body classes the alignment and name of the last block on the page.
https://gist.github.com/jonschr/f56701aebf858fb0733ebc0f49e8b478
Just wondered if you might implement something like this, since having body classes for the last block on the page/post/whatever can be quite helpful (for setting bottom padding on the content area, for example).
The text was updated successfully, but these errors were encountered: