Let’s say I’m pulling text from multiple posts in a MySQL database chronologically using PHP. I want my posts to be displayed as alternatively aligned to right and left.
Importantly, I want the posts to be able to be deleted. If a post is deleted, I want the other posts to retain the dynamic alternating alignment.
Can you give me some ideas on how to do this using CSS?
Use
:oddand:evenpseudoClassese.g.
if you want to retain the previous order after a post deletion, just set
display: nonewhen you remove the post (instead of removing the node from the DOM)If you want instead reposition dinamycally all following posts just remove entirely the node