最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How can I remove the ::after CSS selector which is automaticaly appended to the_content()?

matteradmin8PV0评论

I have a CPT which displays meta values after the_content() in the front end, and this ::after selector is messing with my layout. The selector always appears right after the final element inside the_content().

I have a CPT which displays meta values after the_content() in the front end, and this ::after selector is messing with my layout. The selector always appears right after the final element inside the_content().

Share Improve this question edited Mar 13, 2019 at 12:00 Jacob Peattie 44.3k10 gold badges50 silver badges64 bronze badges asked Mar 13, 2019 at 11:51 bogdanbogdan 1031 gold badge1 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

It has nothing to do with the_content().

::after is a pseudo element that's added with CSS. Note that the ::after element in the dev tools is only there to help development. It does not exist in the HTML source.

So your theme's CSS must be adding it to whatever element is wrapping the_content() in your template. You can remove it by setting content: none; on the selector for it. For example, if the element that's wrapping your content is <div class="entry-content"> then the CSS to remove it could be:

.entry-content::after {
    content: none;
}

The rules of specificity still apply though, so whatever selector you use to remove it needs to be more specific than the one that added it.

Also keep in mind that your theme likely does this for a reason. Most commonly elements like this are used to clear floats and prevent float-aligned content, like images, from breaking outside the parent element.

Post a comment

comment list (0)

  1. No comments so far