:last-of-type Selector Behavior
The :last-of-type pseudo-class targets the last element of a specified type within a parent container. However, in the context of your CSS selector (p.visible:last-of-type), it's important to note that :last-of-type solely applies to element types and not class instances.
In your HTML markup:
This should be hidden
This should be displayed
This should be hidden
The issue arises because :last-of-type targets the last
element, which in this case does not have the .visible class. Consequently, none of your
elements are visible.
Solution
To target the last
element with the .visible class, you must use JavaScript, as there is no built-in CSS selector for this specific purpose.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3